I am a beginner in python and I need some help with a case: I need to print pairs of numbers which are input from a for loop – for example
count_of_numbers = int(input()) for numbers in range(2*count_of_numbers): number = int(input())
Let’s say we enter 3 2 1 4 5 0 4, I need to print the sum of the paired numbers – 3 + 2, 1 + 4 etc. Could anybody brighten me up with an idea on how exactly this is done?
I guess this solves your problem. Try this code in your code compiler. I hope you’ll get your desired output.
count_of_numbers = int(input()) digits =  for numbers in range(1, 2*count_of_numbers): number = int(input()) digits.append(number) for i in range(0, len(digits), 2): if (i + 1) >= len(digits): break print(digits[i] + digits[i+1])