Ask coding questions

← Back to all posts
I have a question
miloplotitsa (0)

maybe you guys try it out but I am having trouble:
When I run it the beginning works perfectly but when I ask the last question it does not respond. I was wondering if there was an answer to this.
https://repl.it/@miloplotitsa/no

for a non link version:

message = ('wait, you just said')
print ('hello')
#not sure what to do with this
first = input ('A, E, __, O, U, and sometimes Y')
second = input('what is the color of the sky and the ocean?')
third = input('what is the opposite of down?')
print (message+first+second+third+'!')
print ('I\'m sorry that\'s just stupid')
print ('I said I am sorry a\'ight?')
friend = input('im sorry okay? can we please be friends?')
if friend == ('yes' or 'y'):
  print ('yay!')
Commentshotnewtop
JustARatherRidi (189)

The problem is that or is usually used to compare two boolean expressions, which means the 2 things on its left and write must have a value of either True or False.

In this case the two things you're asking or to check are

  • Whether 'yes'
  • Or, whether 'y'

That doesn't make much sense, what you're really trying to do is

  • Check whether friend == 'yes'
  • Or, whether friend == 'y'

So what you should have written is

if (friend == 'yes') or (friend == 'y'):
  print('yay!')

A slightly better way of writing the same thing is

if friend in ['yes', 'y']:
  print('yay!')

Your code now works like a charm :)

mkhoi (192)

I tested it... Its works totally fine 🤷‍♂️

ash15khng (306)

For the last question what input are you giving it? If you don't give yes or y nothing gets printed.