Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple Line Input
#1
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!
Reply
#2
Start with a simpler program that reads any number of lines until it meets a line containing only 0.
Reply
#3
(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?
Reply
#4
(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
    
Reply
#5
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Receive Input on Same Line? johnywhy 8 609 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,576 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
Lightbulb Multiple inputs on the same line (beginner) dementshuk 9 2,718 Sep-03-2021, 02:21 PM
Last Post: dementshuk
  How to input & output parameters from command line argument shantanu97 1 2,507 Apr-13-2021, 02:12 PM
Last Post: Larz60+
  How to make input come after input if certain line inserted and if not runs OtherCode Adrian_L 6 3,271 Apr-04-2021, 06:10 PM
Last Post: Adrian_L
  Multiple Line Chart Plotting moto17 1 2,454 Jan-20-2021, 01:38 PM
Last Post: wostan
  Multi-line console input lizze 4 2,285 Dec-26-2020, 08:10 AM
Last Post: lizze
  How to print string multiple times on new line ace19887 7 5,574 Sep-30-2020, 02:53 PM
Last Post: buran
  bad input line 3 how t fix it youssef210 2 2,655 Aug-27-2020, 04:57 PM
Last Post: nilamo
  Line charts error "'isnan' not supported for the input types," issac_n 1 2,368 Jul-22-2020, 04:34 PM
Last Post: issac_n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020