Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While True Problem
#5
You have the while loop in the wrong place. You are supposed to prompt the user for input until then enter a number between 1 and 10. You politely request them to do so, but nothing in you program enforces the thing they enter is a number, much less a number from 1..10.

Your program should look something like this:
while True:
    num = get input
    if num in range 1 to 10
        break
print('&'*num)
Now go figure out these parts:
num = get input # <- You have a good start, but what if user enters 'one'?
if num in range 1 to 10 # <- You have not done anything to test this
Reply


Messages In This Thread
While True Problem - by StingingNeedles - Jan-19-2021, 02:56 AM
RE: While True Problem - by deanhystad - Jan-19-2021, 04:12 AM
RE: While True Problem - by perfringo - Jan-19-2021, 07:32 AM
RE: While True Problem - by StingingNeedles - Jan-19-2021, 04:21 PM
RE: While True Problem - by deanhystad - Jan-19-2021, 04:40 PM
RE: While True Problem - by StingingNeedles - Jan-19-2021, 09:42 PM
RE: While True Problem - by deanhystad - Jan-19-2021, 10:29 PM
RE: While True Problem - by StingingNeedles - Jan-20-2021, 01:18 AM
RE: While True Problem - by deanhystad - Jan-20-2021, 03:59 AM

Forum Jump:

User Panel Messages

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