Skip to content

Instantly share code, notes, and snippets.

@TFlexSoom
Created May 28, 2020 00:02
Show Gist options
  • Select an option

  • Save TFlexSoom/b10b3ce55596ecdb8ea8260cd6d7bbe7 to your computer and use it in GitHub Desktop.

Select an option

Save TFlexSoom/b10b3ce55596ecdb8ea8260cd6d7bbe7 to your computer and use it in GitHub Desktop.
Assignment For Sorting, Lists, and Looping
"""
We have a guessing game. I want you to do the following.
- Collect all the answers into a list
- Rank the answers to how close they were to the number
This means
- Grabbing the absolute difference of each guess and the answer
- putting them into a list
- sorting the list either through the standard library or some algorithm
"""
answer = random.randint(1, 100)
guess = 0
while guess != answer:
guess = int(input("Guess a number between 1 and 100"))
if guess < answer:
print("Too Low!")
elif guess > answer:
print("Too High!")
print("You got it right!")
print("Here are your answers!")
# Print your rankings here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment