Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2017 16:58
Show Gist options
  • Save anonymous/4b752ddef3387e61c4594f0770d8ecdd to your computer and use it in GitHub Desktop.
Save anonymous/4b752ddef3387e61c4594f0770d8ecdd to your computer and use it in GitHub Desktop.
trying to remove an item from a list.
def removeCoin():
coinlist = ["a", "b", "c", "d"]
while True:
print("\nThe list of coins you're currently tracking is: \n" + "\n".join(coinlist) + "\n")
yes_or_no = input("Do you want to remove a coin from the list? (Y/N):").upper()
if yes_or_no == "Y":
try:
coinlist.remove(input("Which coin do you want to remove?").upper())
print("\nThe list of coins you're currently tracking is: \n" + "\n".join(coinlist) + "\n")
except ValueError:
print("There is no such coin in the list")
if yes_or_no == "N":
return coinlist
else:
"You didn't input a valid coin"
removeCoin()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment