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
  Creating new column with a input string drunkenneo 2 695 Apr-14-2021, 08:10 AM
Last Post: drunkenneo
  User input/picking from a list AnunnakiKungFu 2 757 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  .remove() from a list - request for explanation InputOutput007 3 799 Jan-28-2021, 04:21 PM
Last Post: InputOutput007
  Remove double quotes from the list ? PythonDev 22 2,960 Nov-05-2020, 04:53 PM
Last Post: snippsat
  Python win32api keybd_event: How do I input a string of characters? JaneTan 3 1,018 Oct-19-2020, 04:16 AM
Last Post: deanhystad
  Remove specific elements from list with a pattern Xalagy 3 980 Oct-11-2020, 07:18 AM
Last Post: Xalagy
  How to remove char from string?? ridgerunnersjw 2 807 Sep-30-2020, 03:49 PM
Last Post: ridgerunnersjw
  How to remove dict from a list? Denial 7 1,022 Sep-28-2020, 02:40 PM
Last Post: perfringo
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 1,032 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  taking input doesnt print as list bntayfur 2 866 Jun-04-2020, 02:48 AM
Last Post: bntayfur

Forum Jump:

User Panel Messages

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