Skip to content

Instantly share code, notes, and snippets.

@ohr-emet
Last active January 19, 2024 02:37
Show Gist options
  • Save ohr-emet/399742c358206b0587921bba153f1de3 to your computer and use it in GitHub Desktop.
Save ohr-emet/399742c358206b0587921bba153f1de3 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)
@silo3605
Copy link

Thank you so much, it worked out perfectly.

@silo3605
Copy link

Worked perfectly, great coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment