+ 2
How to print Ok in this code
5 Answers
+ 4
You're comparing x to A, but you never even created/assigned anything to a variable A. It'll always be false because A simply doesn't exist in this context.
To answer your question, based upon your code, to print 'Ok' you could do this:
x=input("Result:")
A = x
if x == A:
print("Ok")
else:
print("Something wrong")
^That'll create the variable 'A' and assign the value of 'x' to it so that the condition is true, thus printing 'Ok'
+ 3
Change if x== A:
to this
if x == "A":
+ 3
if x==A
+ 2
x is a String in your if condition you must check it against a String litteral (x == "A" or x == 'A') or check it against a variable that contains a String litteral (x == A after initializing A = 'something' or A = "something")
+ 1
thanks