Skip to content

Instantly share code, notes, and snippets.

@ppeuchin
Last active September 3, 2021 16:21
Show Gist options
  • Save ppeuchin/d4843c03b26217b6f07d458b57504431 to your computer and use it in GitHub Desktop.
Save ppeuchin/d4843c03b26217b6f07d458b57504431 to your computer and use it in GitHub Desktop.
A program that reads integers from the user until the user enters 0 and stores them in a list.
# The program then displays all the values except 0 from the smallest to the largest, with each integer appearing on different lines.
nums_list = []
while True:
num = int(input("Enter an integer: ")
if num == 0:
break
else:
nums_list.append(num)
nums_list.sort()
print("\nResults:\n")
for i in nums_list:
print(" ",i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment