Created
September 7, 2017 16:58
-
-
Save anonymous/4b752ddef3387e61c4594f0770d8ecdd to your computer and use it in GitHub Desktop.
trying to remove an item from a list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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