with input remove a string from the list - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: with input remove a string from the list (/thread-21741.html) |
with input remove a string from the list - konsular - Oct-12-2019 Hello, i cant quite figure why this code doesnt work friends = ["Kevin", "Karen", "jim", "Oscar", "Toby"] variable = input("Delete Kevin? ") if variable = yes: friends.remove("Kevin") print(friends) RE: with input remove a string from the list - Yoriz - Oct-12-2019 if variable = yes:input returns a string, compare to a string of 'yes' if variable = 'yes': RE: with input remove a string from the list - buran - Oct-12-2019 = is assignment== is equalityYou need to use the second one then you will get another error because at the moment yes is a variable and is not defined. You want it to be string in order to compare with the user input
RE: with input remove a string from the list - konsular - Oct-12-2019 thanks a lot! especialy your explanation helped my a lot buran! |