Ask coding questions

← Back to all posts
why is the yess and noo not working?
Imthebestthe (108)

Hey guys! its you boy, someone bad at python. its been a while so i dont really now why this is working.I was asked to make a piecee of code that would simulate a bot makeing a cup of tea so i tried. in my code, i tried to optimise for yes/no questions by makeing a variable containing most of the different varieties of yes and no but when i imput anything, the code just ends, do you know why? thanks!

Answered by Bookie0 (6359) [earned 5 cycles]
View Answer
Comments
hotnewtop
Bookie0 (6359)

Hi!

Lines 6 and 7 you included a list containing different kinds of yes and no. However, on line 8 in the if statement, you did
if yesorno == yess:

but you probably want to do:

if yesorno in yess: # this checks if the input of the user is in the list

same thing on line 17, change it from if yesorno == noo: to:

if yesorno in noo: # checks if user input is in the noo list

Lemme know if you need anymore help or if I was unclear! :)

Imthebestthe (108)

@Bookie0 Thank you so much for this detailed ansere! I will try this by making a smaller project. Thanks very much!

Bookie0 (6359)

ok cool! Lemme know if I can help you more! :) @Imthebestthe

Imthebestthe (108)

hey, quick question, how do you do the def thisng? i want to keep the ccode in one file and not in a lot of others, so how do i do the define thing in line 33

@Bookie0
also, if you want please join here so you can help :
https://repl.it/join/txrfbjgr-imthebestthe

Bookie0 (6359)

@Imthebestthe Hi,

wdym by "the def thing"? def is for functions, so you can keep everything in one file if you want. Looks like you did the function on line 33 correctly but you forgot the () after the function name. Correct version:

def loadingbar():
  #print('makeing')
  toolbar_width = 50
etc.

Does this solve the problem? ;)

Imthebestthe (108)

yh but now it breaks with a error

Do you know why this is happening?
@Bookie0

Bookie0 (6359)

Hum, are you sure you defined it already? Can you link the repel so I can take a look at it? Thanks! :) @Imthebestthe

Wumi4 (539)

At the line when you work with yesorno, 2 lists and the ifs,

if yesorno == yess:
# Other code here, I will not show it

Just replace the == with in, like this:

if yesorno in yess:
# Other code

It should work.

Imthebestthe (108)

@Wumi4 Thank you very much for spending your time to answere this. I really apreciate it. Thanks!

Imthebestthe (108)

Thanks to everyone who decides to help!