Python Forum
I want to check for the smallest value entered by the user - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: I want to check for the smallest value entered by the user (/thread-20461.html)



I want to check for the smallest value entered by the user - Shilpa - Aug-12-2019

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)



RE: I want to check for the smallest value entered by the user - epokw - Aug-12-2019

You are printing out "val" when you meant to print out "smallest", that is why it is returning the most recent number.


RE: I want to check for the smallest value entered by the user - ThomasL - Aug-13-2019

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