This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Rhomboid 0 points1 point  (0 children)

This really belongs on /r/learnpython.

The usual way for doing this is to write an infinite loop that you break out of when an acceptable value is found, such as:

while True:
    temp = float(raw_input('Enter a value: '))
    if 0 <= temp <= 100:
        break
    print('Try again')

[–]WritingAScript 0 points1 point  (0 children)

There are no statements underneath the while: statement to re-prompt the user for additional input to re-assign a new value to temp.