Answer the question
In order to leave comments, you need to log in
How to write down the variables in the number that were entered into the console?
There is a program that writes data to the console:
12 43
32 54
45 76
n = int(input())
Answer the question
In order to leave comments, you need to log in
Have you read anything about the basics of Python? Loops, conditional statements, lists? And if you taught the basics of computer science (school, class probably 7 or 8), then you probably should know that the array was invented in order not to have a "separate variable" for each given one. Based on the confusion of the question, I strongly suspect not. How to translate into Russian the phrase " write down the variables in the amount that were entered into the console ?" - I don't know at all. What does "write variables in quantity" mean?, what is "which were entered into (!!!!) the console" ??? And "in the console" entered variables or all the same their number? ("In the console " (where?) You can "output", but you can enter "
Your program, the one that "writes to the console", how does it know how many pairs are entered? Where does she store her data?
What is n - each separately entered number or previously entered maximum amount of data?
If you work (and have read anything about) Python, you should know that it has a list data type that can grow dynamically and does not require you to predefine the maximum number of its elements. Here, as a new number appears, write it to the list, and if the length of the list is a multiple of two, print its last two elements to the console.
lst=[]
while True:
lst.append(int(input()))
if len(lst)%2==0:
print(lst[-2],lst[-1])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question