Bottom Page

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:
Yoriz wrote Oct-12-2019, 09:20 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
if variable = yes:
input returns a string, compare to a string of 'yes'
if variable = 'yes':
konsular likes this post
= 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
konsular likes this post
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!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  taking input doesnt print as list bntayfur 2 257 Jun-04-2020, 02:48 AM
Last Post: bntayfur
  Remove from end of string up to and including some character lbtdne 2 380 May-17-2020, 09:24 AM
Last Post: menator01
  Remove escape characters / Unicode characters from string DreamingInsanity 5 613 May-15-2020, 01:37 PM
Last Post: snippsat
  Remove all \n from end of list items JackMack118 4 24,154 Dec-27-2019, 08:34 AM
Last Post: perfringo
  Highlight and remove specific string of text itsalmade 5 607 Dec-11-2019, 11:58 PM
Last Post: micseydel
  input string split Eric7Giants 3 607 Nov-13-2019, 07:19 PM
Last Post: Gribouillis
  can't remove element from a list yokaso 6 521 Nov-06-2019, 03:11 PM
Last Post: yokaso
  Help with calling list from user input farispython 5 590 Nov-03-2019, 03:13 PM
Last Post: Gribouillis
  Cannot Remove the Double Quotes on a Certain Word (String) Python BeautifulSoup soothsayerpg 5 1,958 Oct-27-2019, 09:53 AM
Last Post: newbieAuggie2019
  Input while interation in a list doug2019 6 524 Oct-06-2019, 06:44 PM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)