Python Forum

Full Version: I want to check for the smallest value entered by the user
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Below is my code. Instead of getting the smallest value entered by user, i get the last inputted value. I am a beginner so taking baby steps to lean python. Any leads is appreciated. Thanks
largest=None
smallest=None
while True:
    num=input("enter a number")
    if num == 'done':
        break
    try:
         val=int(num)
    except:
        Print("error")
    continue
    if smallest is None:
    smallest=val
    elif:
    val<smallest
    smallest=val
Print("smallest", val)
You are printing out "val" when you meant to print out "smallest", that is why it is returning the most recent number.
As provided your code won´t run as there are a lot of bugs.
Indentation is sometimes wrong and print() is written with lower p and not capital P
elif: won´t work either