Help with a simple Python program

  • Context: Python 
  • Thread starter Thread starter 2sin54
  • Start date Start date
  • Tags Tags
    Program Python
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 2K views
2sin54
Messages
109
Reaction score
1

Homework Statement


Hello. I want to write a program which finds the largest number in the sequence typed in by the user. However, when I type in a number it not only gets printed as the input value but gets re-printed as if I have done the print function of that number (though the final answer is correct). How can I solve this issue and make the program cleaner?

2. The attempt at a solution
Code:
seq = [0]
n = int(input("Start typing the sequence (end it with 0)"))
while (n!=0):
        n = int(input(n))
        seq = seq + [n]
print ("The largest number in the sequence is " + str(max(seq)))
 
Physics news on Phys.org
jedishrfu said:
try entering the numbers on one line and use the .split(" ") to separate them into an array of values

How do I enter them in one line? Why does the 'input' function force the numbers to be written in different lines?
 
----- Solved it. Thanks for the help.
 
Last edited: