Python Forum

Full Version: Multiple Line Input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I need a python program that asks the user to enter any number of lines with each line containing 5 natural numbers separated by a space. The zero will designate the end of the input. It then prints out prime numbers corresponding to each row. If the line doesn't have any prime numbers, it prints none. For example:
Sample input
9 8 7 6 5
11 2 3 4 5
4 6 8 10
0
Sample output
7 5
11 3 5
None

I don't know where to start, if someone would please help me that'd be great!
Start with a simpler program that reads any number of lines until it meets a line containing only 0.
(Dec-01-2019, 10:49 PM)Gribouillis Wrote: [ -> ]Start with a simpler program that reads any number of lines until it meets a line containing only 0.
how would i do that?
(Dec-01-2019, 11:13 PM)helenaxoxo Wrote: [ -> ]
(Dec-01-2019, 10:49 PM)Gribouillis Wrote: [ -> ]Start with a simpler program that reads any number of lines until it meets a line containing only 0.
how would i do that?
Here is a starting point. Hope that helps to get you on track to the solution.
end=False
while not end:
    x=input()
    if x=="0":
        end=True
    
(Dec-02-2019, 08:19 AM)midarq Wrote: [ -> ]
(Dec-01-2019, 11:13 PM)helenaxoxo Wrote: [ -> ]
(Dec-01-2019, 10:49 PM)Gribouillis Wrote: [ -> ]Start with a simpler program that reads any number of lines until it meets a line containing only 0.
how would i do that?
Here is a starting point. Hope that helps to get you on track to the solution.
 end=False while not end: x=input() if x=="0": end=True 

Thank you!