[Tutor] python help

boB Stepp robertvstepp at gmail.com
Sat Sep 12 13:44:01 EDT 2020


On Sat, Sep 12, 2020 at 12:37:13PM -0500, boB Stepp wrote:
>Hello!
>
>On Sat, Sep 12, 2020 at 03:35:53PM +0000, trista rayment via Tutor wrote:
>>I need to write a code that asks for a number between 5 and 25 and only allows integers and if a non integer is entered it needs to print 'you must enter an integer'  or if it types a number less than 5 or more than 25, it needs to re-ask the original question until it gets an appropriate answer
>>would it be better to form an else if or a range or is there a more effective function to put in my code? 
>>my first thought would be:
>>print('Enter an integer between 5 and 25')howMany = input()
>
>Are you aware that "input()" can display a prompt to the screen?  So what
>you have here could be written:
>
>howMany = input("Enter an integer between 5 and 25)

Argh!  I forgot a pair of quotes.  The above should be:

howMany = input("Enter an integer between 5 and 25")

-- 
Wishing you only the best,

boB Stepp


More information about the Tutor mailing list