Ask coding questions

← Back to all posts
I need help.
Nuuh123 (0)

Can somebody please explain why ot won't usse the "else statement"?

malvoliothegood (148)

The if/else conditional works OK when I test it. Maybe you fixed the issue since making your help request.

malvoliothegood (148)

friend is only being tested against "yes", not the rest of the possible positive answers. This code does the job:

yeses = ["yes", "yeah", "Yes", "Yeah", "sure", "Sure"];

if(friend in yeses ):
  print(f"yay! the {variable2} year old {variable} is my friend!")
  # it doesn't want to use the else statement
  print(f'{variable}... you don\'t want to be my friend? :,(')
Nuuh123 (0)

@malvoliothegood Thanks! I just learned something in less than a minute! I love this Website.