0

Any python coders..I've faced a problem...in this program, if statement to be executed but not...why?resolve plz

import random from random import randrange a=[5,6,9,8] print(random.choice(a)) b=randrange(2) print(b) print(randrange(200)) c=input("Enter the number:") if b==c: print("You have Entered Correct Number") else: print("Good try..!!") print("But answer is",b) OUTPUT: 6 0 129 Enter the number:0 Good try..!! But answer is 0

30th Aug 2017, 12:46 AM
Vignesh R
Vignesh R - avatar
2 Respuestas
+ 6
I'm not a Python guy, but by a glance I assume the issue is that c is a String. (input("") returns a String) Convert it to an int (number) to compare it with b. Like this: c = int(input("Enter a number."))
30th Aug 2017, 1:23 AM
Rrestoring faith
Rrestoring faith - avatar
0
oooh..okay I'll check...thakss
30th Aug 2017, 1:41 AM
Vignesh R
Vignesh R - avatar