Python Help with a simple Python program

  • Thread starter Thread starter 2sin54
  • Start date Start date
  • Tags Tags
    Program Python
AI Thread Summary
The discussion focuses on a programming issue related to finding the largest number in a user-input sequence. The user encountered a problem where each input number was printed back to the console, making the program output cluttered despite correctly calculating the largest number. A suggested solution involved using the `input()` function with a prompt and entering numbers on one line, utilizing the `.split(" ")` method to separate them into an array. The user successfully resolved the issue after receiving guidance, indicating a clearer understanding of how to handle input in Python.
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)))
 
Technology news on Phys.org
try entering the numbers on one line and use the .split(" ") to separate them into an array of values
 
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:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top