You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why can you not run code similar to this?:
def function(a,b,c):
if (a, b, c) == type(str):
return True
or like this:
def function(a,b,c):
if(a and b and c) == type(str):
return True
Why does it only work if I run it like this?:
def all_strings(a, b, c):
if type(a) == str and type(b) == str and type(c) == str:
return True
return False
The text was updated successfully, but these errors were encountered:
Because (a, b, c) is a tuple which is a sequence of python objects. Each object could be of any type or class so in order to check the type of each object in your tuple, you would have to do something similar to what you have written if (type(a) == str) and (type(b) == str) and (type(c) == str):
Why can you not run code similar to this?:
def function(a,b,c):
if (a, b, c) == type(str):
return True
or like this:
def function(a,b,c):
if(a and b and c) == type(str):
return True
Why does it only work if I run it like this?:
def all_strings(a, b, c):
if type(a) == str and type(b) == str and type(c) == str:
return True
return False
The text was updated successfully, but these errors were encountered: