Python Forum
with input remove a string from the list - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/Forum-Python-Coding)
+--- Forum: General Coding Help (https://python-forum.io/Forum-General-Coding-Help)
+--- Thread: with input remove a string from the list (/Thread-with-input-remove-a-string-from-the-list)



with input remove a string from the list - konsular - Oct-12-2019

Hello,

i cant quite figure why this code doesnt work Wall

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 equality
You 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!