+ 1

If and else confusement

im build a script with python in linux.the python version:2.7 here the example script tanyatb = (str(raw_input("do u know how many that? Y/N "))) if (tanyatb==("y")or("Y")): print("its working") else: print("its not working") idk know why raw_input is defined in here, but when i input that 'y' its print 'its working'.but when i input 'n' its print ' its working' too.im tried if (tanyatb!=("y")or("Y")): and if not(tanyatb==("y")or("Y")): then im input 'n' , 'its working'.how to print 'not working'?

10th Jul 2017, 4:28 AM
Kevin AS
Kevin AS - avatar
4 Answers
+ 1
There are a a few errors here you don't need to convert raw_input to a string tanyatb = raw_input("do u know how many that? Y/N ") will work fine You also don't need brackets in your if statement if tanyatb.lower() == "y": print("it's working") else: print("it's not working")
10th Jul 2017, 4:40 AM
Cailyn Baksh
+ 1
working well.u just help my big project,thnx
10th Jul 2017, 4:48 AM
Kevin AS
Kevin AS - avatar
0
raw_input is not defined in learn python
10th Jul 2017, 4:29 AM
Kevin AS
Kevin AS - avatar
0
yeah,solo learn code playground sucks.i will try that.thnx
10th Jul 2017, 4:41 AM
Kevin AS
Kevin AS - avatar