Tags
python , ===
Asked 3 years ago
6 Aug 2021
Views 544
Ernest

Ernest posted

Is the following Python code valid : checking value by === ( Triple equal ) ?

Is the following Python code valid ?


a =1223
b="1223"
print(a===b)


what is wrong in above Python code ,
print(a===b)
^
SyntaxError: invalid syntax

it work with == but not === in python , where i want to check type and value as like PHP have ===
sachin

sachin
answered Aug 6 '21 00:00

there is no === operator in python, in another hand for checking the type and value of the variable you can use "is" or == operator

below code is work without error :

a =1223
b="1223"
print(a==b)


it will print False because type and value of a and b is not equal


a =1223
b="1223"
print(a is b)


it will print False because type and value of a and b is not equal
Post Answer