Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionals on arguments #25

Open
JeremyMH opened this issue Oct 26, 2017 · 1 comment
Open

Conditionals on arguments #25

JeremyMH opened this issue Oct 26, 2017 · 1 comment

Comments

@JeremyMH
Copy link

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

@abeanari
Copy link

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):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants