I'm quite new in Python, and am learning through FreeCodeCamp. This website is wonderful but that's not the point here.
I'm trying (for learning purpose), to create a little program, that pick the greatest and smallest number of a list given as an input :
smallest = None
greatest = None
print(' Type "Done" when you want the program to stop.')
while True:
value = input('Enter your number :')
if value == 'Done' or value == 'done':
break
try:
int(value)
except:
print('Please enter a number')
continue
if smallest is None:
smallest = value
if greatest is None:
greatest = value
if value < smallest:
smallest = value
print ('Smallest :', smallest, 'Greatest :', greatest)
continue
if value > greatest:
greatest = value
print ('Smallest :', smallest, 'Greatest :', greatest)
continue
if greatest >= value >= smallest :
print ('Smallest :', smallest, 'Greatest :', greatest)
continue
print('Smallest is :', smallest, ' Greatest is :', greatest)
The problem I am encountering, is that it looks like the < & > operators are only comparing the first digit, then the second ...
Here's the result I have :
Enter your number :123
Smallest : 123 Greatest : 123
Enter your number :2
Smallest : 123 Greatest : 2
Enter your number :123
Smallest : 123 Greatest : 2
Enter your number :done
Smallest is : 123 Greatest is : 2
I don't understand this behavior, so maybe someone here will get the answer !
Thank you and have a nice day