Skip to content

Instantly share code, notes, and snippets.

@wafiqsyed
Created July 1, 2019 16:40
Show Gist options
  • Save wafiqsyed/67cfa19684f4878012647e0ece1df980 to your computer and use it in GitHub Desktop.
Save wafiqsyed/67cfa19684f4878012647e0ece1df980 to your computer and use it in GitHub Desktop.
Python Tutorials - While loop: find the largest number from a large set of entered data
# Choose a low number and make it the current max number
max = -99999999
# get the first value from user
number = int(input("Enter value or -1 to stop: "))
# if the number is not equal to -1, execute the following loop
while number != 1:
if number > max: # if the number entered is greater than the current max number,
max = number # store this number as the max number
number = int(input("Enter value or -1 to stop: ")) # keep asking for input until user inputs -1 to quit
print("The largest number from the numbers you entered is:", max) # Prints the maximum number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment