Skip to content

Instantly share code, notes, and snippets.

@silo3605
Forked from ohr-emet/py4e_5_2.py
Created January 19, 2024 02:36
Show Gist options
  • Save silo3605/e2431eea5d92fb30849b43aa07d87af7 to your computer and use it in GitHub Desktop.
Save silo3605/e2431eea5d92fb30849b43aa07d87af7 to your computer and use it in GitHub Desktop.
py4e 5.2 Assignment - [Solved, Working solution] [Only review after you have tried _everything_ ]
largest = -1
smallest = None
while True :
num = input('Enter a number: ')
if num == "done" :
break
try:
i_num = int(num)
except:
print('Invalid input')
continue
if i_num > largest:
largest = i_num
if smallest is None :
smallest = i_num
elif i_num < smallest :
smallest = i_num
print("Maximum is", largest)
print("Minimum is", smallest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment