Python Forum
with input remove a string from the list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
with input remove a string from the list

i cant quite figure why this code doesnt work Wall

friends = ["Kevin", "Karen", "jim", "Oscar", "Toby"]
variable = input("Delete Kevin? ")
if variable = yes:
if variable = yes:
input returns a string, compare to a string of 'yes'
if variable = 'yes':
= 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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

thanks a lot!

especialy your explanation helped my a lot buran!

Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove a space between a string and variable in print sie 5 280 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  How do I remove spurious "." from a string? Zuhan 7 679 Apr-12-2022, 02:06 PM
Last Post: Pedroski55
  Remove empty keys in a python list python_student 7 882 Jan-12-2022, 10:23 PM
Last Post: python_student
Big Grin General programming question (input string)[ jamie_01 2 603 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Remove an item from a list contained in another item in python CompleteNewb 19 2,552 Nov-11-2021, 06:43 AM
Last Post: Gribouillis
  Creating new column with a input string drunkenneo 2 1,314 Apr-14-2021, 08:10 AM
Last Post: drunkenneo
  User input/picking from a list AnunnakiKungFu 2 1,444 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  .remove() from a list - request for explanation InputOutput007 3 1,382 Jan-28-2021, 04:21 PM
Last Post: InputOutput007
  Remove double quotes from the list ? PythonDev 22 5,080 Nov-05-2020, 04:53 PM
Last Post: snippsat
  Python win32api keybd_event: How do I input a string of characters? JaneTan 3 1,938 Oct-19-2020, 04:16 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020