@@mage1over137 I don’t think it’s that unreasonable for “or” to function like that in a programming language, obviously that’s not how it works here but it absolutely could function like that in some language
I’m not sure if this is “tricky”. I come from a mostly C based programming languages and I’ve never seen a PL do x == 1 || 2 || 3 before. If anything, the ability to do that makes it tricky.
@@rorymax Yeah and if I remember Python correctly (I’m a low level dev lol) if [‘Bob’, ‘Nancy’, ‘Tom’].contains(name): You could do something like that
@@pacifist1354 you can use a tuple instead of a list to take up less memory and be faster for basically no cost and use the "in" thingy so it's better to do if name in ('Bob', 'Nancy', 'Tom')
@@blablabla7796 Yeah, I was gonna say the same thing. The 'or' statement in Python is a direct replacement for '||'. It does the exact same thing. It would be tricky if it behaved differently for some reason (and that would make it harder to use). If you wanted to make an if statement check if someone's name is equal to a string, or their id is equal to an int, an "or" statement behaving like any other "or" statement makes that easy, but if it behaved the other way, you would not be able to compare two different variables with two different types without nesting if statement.
I actually ran into this issue and it stumped me for a week. Eventually someone told me that the other options arent being checked against the "name" variable. Thank you again for yet another great tutorial!
Why would it be better to create a tuple? This is a lost of users that have access to something. That list most definitely will change. It may be faster to create a tuple, but how many times are you going to have to create it, convert it, append, and make it a tuple once again?
Reminds me of an error I had in java where the == operator didn't only check if the string was the same but if they had the same origin. So when I imported a name from another class it would always return false. Found out that you can just use object1.equals(object2).
If the `list` only has 4 values, it's ok to use `in`, but if it gets bigger you should always use a `set` (replace `[]` by `{}`) because it's more efficient when using `in`
@@maanavsingh1914 That's why we should store the set in a variable, to ensure that any Python interpreter doesn't build the set every-time we access it. But, IIRC, CPython already recognizes constant sets, and uses memoization to avoid further re-computations
@@Rudxain memorization refers to caching the results of a function. Doesnt haven’t much to do with this example. Sure if we had multiple invocations of this conditional check and there were a lot of names performance would improve but looking at this specific code that doesn’t apply. No static analysis by the interpreter can magically skip the instantiation cost of a set. You have to pay the cost at some point and it’s not worth it for this example.
@@maanavsingh1914 I realized I used the wrong term: it's not memoization, it's lazy-evaluation with sharing. About the performance part, that's what I said! (Sort of) linear searches are faster than hash functions and logarithmic searches for small sequences of values
yeah, this used to be one of the problems I used to face but then I figured it out myself to use the in operator, you could use tuple or dictionary also but if it's a dictionary, it's only gonna check the key but not the value.
@@the_agent_z Rust is amazing, but you do not even need Rust to avoid this specific quite basic language design error. Even in C#, Java or Go your program is not going to compile.
If it was any other language I would say it would print 'Access granted', but knowing that stuff like 2 < x < 6 works as expected in python I wans't sure here.
This is actually how a teacher first told me about boolean values. I was trying to test if a character was 'a' or 'A' and ended up having an always true condition
It is and many languages will behave like that. Some with better type guarantees won't let that compile. It is still a good tip for the very beginning because that syntax reflects how we talk and in python it runs so it can cause bugs
@@corlaez The "broken" code is still valid code though, and had 0 bugs. This isn't a good argument for static type checking. If it were to give a runtime error, I'd give you credit, but the code was completely valid
When I see things like this I think 3 things... 1. ALWAYS test your code, never asume. 2. Python is still not as terrible with this kind of things as JavaScript with all it's weird type coercions. Here everything is translated into a boolean expression but in JS you can even confuse all kinds of numbers, strings and objects in weird ways. 3. This is why programming languages with an actually strong and strict type system are best. You cannot make this type mistake in those languages, because it will not compile but fail immediately.
Reasoning behind this: Strings are always True, which means you are comparing True to True, which amazingly is True. Edit: In the context of this snippet, this is not correct. It is because 'Tom' and 'Mike' are strings, which evaluate to True, so it is actually checking for "if False or True", which means regardless it will return True.
Back when I started learning programming, I ran into this exact issue. Now I work as a full stack engineer at one of the largest companies in the world. I don't say that to flex, but to say, you're going to make silly errors or not quite get something the first time. Programming is an activity you can (and probably will) fail at over and over, and as long as you hold onto that hunger to learn and don't let yourself get too discouraged, you'll be fine. I will flex about the fact that I asked about this error on stack overflow and made it out with all of my body parts still attached though.
Every programmer writing in some language with a loosely, dynamically or otherwise lacking type system is going to run in this type of problem. Definitely great for learning experience. But for me also a reason why I love languages with properly designed type systems so much. Safety over easiness. Finding your bugs early will be easier in the end.
That's why I'm a fan of languages that don't force indentation.( C, C++ etc) because confusion like these are quite rare while coding in C++ even javascript.
Fun fact (although the logical flaw in the reasoning here should be pretty obvious): If you add parens around the if (and add the type decl.) the code will compile in c++ and produce the wrong result as well (yep or has been a keyword for decades at this point).
can you elaborate? This is the exact kind of error you'd get in almost any language - this might be stopped by more srict typing, but surely not by indentation, indents have nothing to do with lesser readability (how would forcing readability through indention be a disadvantage anyways?) nore semantics here.
I would not try defend JS with anything like this. JS is fun, but it's absolute garbage language design with all it's type coercions. In Python you can still make boolean logic with everything apparently, but not twist everything like you can in JS. I prefer languages with actual proper type systems though.
I think in this situation you should use cortege because list grab more memory. You don't need to append or remove values from list. So cortege is nice opportunity.
Exactly. The video showing why “Python is not programming” and showing something that doesn’t work in C++, C#, Java, JS, TS as well is just hilariously dumb
@@thomasn5726 the video is why “Python is not Pythoning”. Yes, this is a common error in programming languages, but it’s a particular rough spot in a language that is generally touted for its readability.
@@chase-2-2 well, it depends moreso on whether or not the language requires explicit conditionals. ‘name == “Bob” || “Tom” || “Mike”’ will throw an error in a language like Go, because Go says you have to explicitly compare your variables/literals to something. Yet C won’t throw an error because C only cares if the condition is some variation of zero (eg NULL) or non-zero value.
Rather than using a list to check because it is processing heavy you can use If name=='bob' or name=='tom' or name=='mike': This is not processing heavy
I wouldn't do the list just because of the time complexity of checking if it's in the list. It's better to use a set or type out the individual comparison statements
If you're going to use those names repeatedly, make them a set (or a dict if you need to map them to something) rather than a list, so the check time is O(1), not O(n).
thank you, this really.helped me I was wondering why my if statement was returning true even if the input is false. this is very helpful specially for a begginer like me
A string being a same as true is not great design. Sure it might make somethings feel simpler but it's a massive footgun you generally don't get in statically typed languages.
I like this can of video where there is a little problem and I have to understand why the code do that. I'm beginning to learn python, so it's a good way to avoid mistake next time I use if
@@farhanaditya2647 in this exemple, no it will not, but when you teach something, it's important not to teach also bad practices, even if it is a small mistake. Otherwise, beginners could get use to this bad practices.
It's a bit confusing but actually make sense when you take into account wanting empty value to evaluate to false. The other on "False" or Boolean("False") are both evaluated as True.
one thing that was confusing is when he first told you the corrected code he said you can fix it by "name equals bob or if name equals tom etc" but he doesnt actually type that out on screen. I understood what was happening but I wonder how many people this would just confuse. it would If name == 'Bob' or name == 'Tom' or name == 'Mike' which is really wordy and effectively the same logic as the if name in ['a','b','c'] because that statement is effecitveley doing a truth check against the name value and every item in list.
I've just started learning Python and I keep making this mistake. Glad to see that's why it does it the way it does, in retrospect it makes sense it evaluates the other two as true
Everyone is fighting about static or dynamic typing in C/Python, but a beginner can’t make a mistake like this when you can’t use a string where a Boolean goes.
“if name in” is more pythonic, but this behavior is really just a general programming concept. . Conditional statements are entirely separate from one another, but the lack of required parentheses in Python makes it harder to spot. If you wrote it in js, for example, like “if (name == “Chris” || “Tom” || “Mike”) it’s easier to spot the problem.
The thing is, this quirk appears in other languages, but with a slight change of conventions. Java for example allows objects without any comparison to act as boolean values in conditional statements, so the standard is that null objects are always considered false. That's how I could guess
Then it would be an array wouldn’t it? I come from C based programming languages but I am pretty sure every language has pretty much (if not) the same variable system
Basic thing to remember: even though sometimes you can read Python like English, Python is not English.
Yeah I actually thought this was a weird thing to cover. Of course you can't use "or" statements like that.
Well said, man!
@@mage1over137 I don’t think it’s that unreasonable for “or” to function like that in a programming language, obviously that’s not how it works here but it absolutely could function like that in some language
This needs to be written in all caps on every billboard...
@@jonathanalexander9881:)
I had to discover that by myself, I wish I knew that before 🤧
Yeah, i needed to discover it the hard way 😔
same was to me about a year ago
Same here it took 3 days to discover in my code😭😭
No u don’t
This is the right way to learn
Yah same, so painful :(((
i managed to figure this out. not because im smart but because ive been dumb, many, many times
Put that shit on a shirt
that's the definition of a smart person, someone who has been dumb. don't beat yourself down!
As long as you keep trying, then you’re doing good
You have been quoted
Nah your smart. You know you’ve been dumb many times. But you recognize and know that.
These statements are almost always in other languages as if(name == "name1" or name == "name2") so seeing this statement immediately raises red flags
It's also weird that Python lets you evaluate a string as a boolean
@@YoshiAsk its called truthyness, its actually very useful. just makes code more concise
@@gigachad8810 yea... Idk what u talking about but why its so confusing Like u cloud just put the strings into brackets with or
thats what im saying bro why make it difficult
@@ImmortalSpelldaggerC/C++ does this type of stuff too
Theres tricky things like this in almost every language! This was great to learn!
I’m not sure if this is “tricky”. I come from a mostly C based programming languages and I’ve never seen a PL do x == 1 || 2 || 3 before. If anything, the ability to do that makes it tricky.
@@blablabla7796 yeah but in python you can do things like 1
@@rorymax Yeah and if I remember Python correctly (I’m a low level dev lol)
if [‘Bob’, ‘Nancy’, ‘Tom’].contains(name):
You could do something like that
@@pacifist1354 you can use a tuple instead of a list to take up less memory and be faster for basically no cost and use the "in" thingy
so it's better to do
if name in ('Bob', 'Nancy', 'Tom')
@@blablabla7796 Yeah, I was gonna say the same thing. The 'or' statement in Python is a direct replacement for '||'. It does the exact same thing. It would be tricky if it behaved differently for some reason (and that would make it harder to use).
If you wanted to make an if statement check if someone's name is equal to a string, or their id is equal to an int, an "or" statement behaving like any other "or" statement makes that easy, but if it behaved the other way, you would not be able to compare two different variables with two different types without nesting if statement.
can you do more of this simple tips in syntaxes please
I actually ran into this issue and it stumped me for a week.
Eventually someone told me that the other options arent being checked against the "name" variable.
Thank you again for yet another great tutorial!
Python: does something slightly not pseudo code
People: why is Python not Pythoning????
We really need the "anything pseudo code" to machine code programming language.
what color is your buggati
Its not even pseudo code lol you would still have to say:
name is name1 or name is name2 or name is name3
@@MrPuzzleCodeswat
@@DarkNexarius powered by an AI interpreter
better to use a tuple over a list, since inmutables have better read, and creation speeds
For performance-wise, I agree. But in data analysis, as long as the results are to be expected, it doesn't matter
Not just performance. To the reader tuple means this is a closed list and should not be changed (the immutablilty is for the coder, not the machine)
When checking for 3 values in python, your first thought definitely shouldn't be how to shave off a picosecond lol
Why would it be better to create a tuple? This is a lost of users that have access to something. That list most definitely will change. It may be faster to create a tuple, but how many times are you going to have to create it, convert it, append, and make it a tuple once again?
if it is literal (it is already known compile time), then use tuple.
Reminds me of an error I had in java where the == operator didn't only check if the string was the same but if they had the same origin. So when I imported a name from another class it would always return false. Found out that you can just use object1.equals(object2).
That is the actual way how you compare two strings in java
@@bhw_msq Learnt it the hard way :(
Yeah that's one of the really weird things about java and something that's luckily fixed in kotlin
Oh crap. That's true indeed. In C# you do not have that problem.
And in Rust you have even less problems.
Haha yep that's the reason I consult the documentation every time I am doing a comparison in a language I don't use that often
If the `list` only has 4 values, it's ok to use `in`, but if it gets bigger you should always use a `set` (replace `[]` by `{}`) because it's more efficient when using `in`
Except that it’s O(n) to build the set anyways and it’s several times slower to build a set than linear scan a list…
@@maanavsingh1914 That's why we should store the set in a variable, to ensure that any Python interpreter doesn't build the set every-time we access it. But, IIRC, CPython already recognizes constant sets, and uses memoization to avoid further re-computations
@@Rudxain memorization refers to caching the results of a function. Doesnt haven’t much to do with this example. Sure if we had multiple invocations of this conditional check and there were a lot of names performance would improve but looking at this specific code that doesn’t apply. No static analysis by the interpreter can magically skip the instantiation cost of a set. You have to pay the cost at some point and it’s not worth it for this example.
@@maanavsingh1914 I realized I used the wrong term: it's not memoization, it's lazy-evaluation with sharing.
About the performance part, that's what I said! (Sort of) linear searches are faster than hash functions and logarithmic searches for small sequences of values
that keyboard is so satisfying 😊
There actually exists a think like ASMR programming on YT.
Although most of these codes will probably show you satisfying results instead. :P
I did that when i first started programming but now I don't find myself making that mistake as often
The output will be “next time bring Bob, Tom, or Mike with you”
yeah, this used to be one of the problems I used to face but then I figured it out myself to use the in operator, you could use tuple or dictionary also but if it's a dictionary, it's only gonna check the key but not the value.
The fact that i already knew how to use the collection in the if statement amazes me a lot how easy is to use it.
That’s why I like explicit typing and type safty so much
rust user?
Spill!
@@the_agent_z Rust is amazing, but you do not even need Rust to avoid this specific quite basic language design error.
Even in C#, Java or Go your program is not going to compile.
If it was any other language I would say it would print 'Access granted', but knowing that stuff like 2 < x < 6 works as expected in python I wans't sure here.
lmao
Nice to know! I'm just starting to really learn coding and these shorts help a ton :)
only real OG's knew the error before he told you
Keep holding onto that dumb superiority complex. See if it does anything for you in life.
This is basic stuff. The even better way is to use a tuple instead of list.
wooow og
@@incremental_failure I agree, for both things you said.
@@ba7260 Yes, but the syntax is different with languages
great stuff man, simple details like this make big impacts.
Used to do this when I was first learning Javascript
This is actually how a teacher first told me about boolean values.
I was trying to test if a character was 'a' or 'A' and ended up having an always true condition
As a JavaScript developer Python looks easier to use.
While that is true javascript is way more powerful, efficient and fast than python.
Paused the video before the result, realized after a few seconds and felt so proud
Ahh I too remember day 2 of being a programmer.
toxic
@@marijn17s why is that toxic, it's just a normal comment.
@@sunpoke5317 you have to understand the deep meaning behind that comment
@@creed404 none?
@@creed404 it ain't that deep bro
Hey bool these videos are game changing, u got something really special here I hope you know that
I already figured out by myself the name == "name", but I didn't know about the name in ["name"] is very helpful thankyou
Thanks!
Wow! Thank you so much!!
i am literallly learning python from yt shorts
learning is good
U are really helping in my journey of learning python
Isn't that a normal behaviour of chaining conditions ?
It is and many languages will behave like that. Some with better type guarantees won't let that compile.
It is still a good tip for the very beginning because that syntax reflects how we talk and in python it runs so it can cause bugs
mhm, this video is just for ppl who aren't familiar with them. it's equivalent to kids first learning about why 2 + 2 * 2 isnt 8
@@corlaez The "broken" code is still valid code though, and had 0 bugs. This isn't a good argument for static type checking. If it were to give a runtime error, I'd give you credit, but the code was completely valid
I loved the part when Python said "It's python'ing time" and python'ed all over the place
Truly one of the programming languages of all time
It's berdin time
Truly the programming languages ever
This is the most programming language i ever saw
Great video! I just learned about lists, and recently did the lessons on bools, and this was fun to follow along with 😊
havent pressed play yet, its going to print access granted because non-empty strings are truthy
yep was exactly right. good syntax video!
This solved an issue I had for so long with making a password and username login, thank you so much!
I really needed that information like 48 hours ago before I made ~30 elif's
You should use switch statements
Currently learning Python and I came across this problem. Took me a good amount of time to figure out
truthyness is always a footgun. I prefer when you need to explicitly coerce values
When I see things like this I think 3 things...
1. ALWAYS test your code, never asume.
2. Python is still not as terrible with this kind of things as JavaScript with all it's weird type coercions. Here everything is translated into a boolean expression but in JS you can even confuse all kinds of numbers, strings and objects in weird ways.
3. This is why programming languages with an actually strong and strict type system are best. You cannot make this type mistake in those languages, because it will not compile but fail immediately.
Reasoning behind this:
Strings are always True, which means you are comparing True to True, which amazingly is True.
Edit: In the context of this snippet, this is not correct. It is because 'Tom' and 'Mike' are strings, which evaluate to True, so it is actually checking for "if False or True", which means regardless it will return True.
Thanks! Was looking for this. ^^
That's a really useful tip, thank you
Back when I started learning programming, I ran into this exact issue. Now I work as a full stack engineer at one of the largest companies in the world. I don't say that to flex, but to say, you're going to make silly errors or not quite get something the first time. Programming is an activity you can (and probably will) fail at over and over, and as long as you hold onto that hunger to learn and don't let yourself get too discouraged, you'll be fine.
I will flex about the fact that I asked about this error on stack overflow and made it out with all of my body parts still attached though.
Every programmer writing in some language with a loosely, dynamically or otherwise lacking type system is going to run in this type of problem.
Definitely great for learning experience.
But for me also a reason why I love languages with properly designed type systems so much.
Safety over easiness.
Finding your bugs early will be easier in the end.
Thank you for this, was lost on this concept today
That's why I'm a fan of languages that don't force indentation.( C, C++ etc) because confusion like these are quite rare while coding in C++ even javascript.
Fun fact (although the logical flaw in the reasoning here should be pretty obvious): If you add parens around the if (and add the type decl.) the code will compile in c++ and produce the wrong result as well (yep or has been a keyword for decades at this point).
can you elaborate? This is the exact kind of error you'd get in almost any language - this might be stopped by more srict typing, but surely not by indentation, indents have nothing to do with lesser readability (how would forcing readability through indention be a disadvantage anyways?) nore semantics here.
@@Rubyd777 i don't get it. This error has nothing to do with indention and would occur in the same way in C
@John der Don oops sorry i mistakenly mentioned you
I would not try defend JS with anything like this. JS is fun, but it's absolute garbage language design with all it's type coercions. In Python you can still make boolean logic with everything apparently, but not twist everything like you can in JS.
I prefer languages with actual proper type systems though.
I think in this situation you should use cortege because list grab more memory. You don't need to append or remove values from list. So cortege is nice opportunity.
And that's how any normal programming language works
Lua is easier
Exactly. The video showing why “Python is not programming” and showing something that doesn’t work in C++, C#, Java, JS, TS as well is just hilariously dumb
Dynamically typed languages, yes. But statically typed languages (which are the majority) will throw a compiler error here
@@thomasn5726 the video is why “Python is not Pythoning”. Yes, this is a common error in programming languages, but it’s a particular rough spot in a language that is generally touted for its readability.
@@chase-2-2 well, it depends moreso on whether or not the language requires explicit conditionals. ‘name == “Bob” || “Tom” || “Mike”’ will throw an error in a language like Go, because Go says you have to explicitly compare your variables/literals to something. Yet C won’t throw an error because C only cares if the condition is some variation of zero (eg NULL) or non-zero value.
The second way is better because you can update the list during runtime.
Rather than using a list to check because it is processing heavy you can use
If name=='bob' or name=='tom' or name=='mike':
This is not processing heavy
generally name in [...names] is prefered, as proformance loss here is negligable. He's not checking for millions of names lol
Thank you so mych for explaning this. Saved me so much trouble!
poor Chris😢
🥲🤣🤣🤣
Add last names as a second variable, or possibly ID’s aswell
This is why I code in real programming languages.
Its funny you say that actually because the equivalent of this in other languages will give you the same result💀
fun fact, its the same thing for every lenguage, you cant do "if a==1 or 2 or 3" its always "if a==1 or a==2 or a==3"
Congrats on discovering the most basic things in programming: conditions!
Truthy and falsy
I wouldn't do the list just because of the time complexity of checking if it's in the list. It's better to use a set or type out the individual comparison statements
If you're going to use those names repeatedly, make them a set (or a dict if you need to map them to something) rather than a list, so the check time is O(1), not O(n).
you can make a list variable so you dont have to type [name1, name2, name3] all the time
The intersection between logic and syntax is what makes me realize i don't think coding is meant for me
Even as someone who knew this already, this question still threw me for a loop
you can also use set, because item in set() is O(1) most of the time, but same with list is O(n)
Anyone else think you shouldn't be able to implicitly convert an object to a boolean
thank you, this really.helped me I was wondering why my if statement was returning true even if the input is false. this is very helpful specially for a begginer like me
Somebody know the theme? I love the way it looks.
I love using array (list) in this case
or is just to add additional conditions not the condition itself
it is by design guys, theres a lot of use case in which this is actually the prefered behavior
A string being a same as true is not great design. Sure it might make somethings feel simpler but it's a massive footgun you generally don't get in statically typed languages.
It's like google knew what problem i had in python
Literally didn’t know that list thing that’s helllla useful 😊
I like this can of video where there is a little problem and I have to understand why the code do that. I'm beginning to learn python, so it's a good way to avoid mistake next time I use if
You have to write this code like this:
if (name == x) or (name == y) or (name == z):
print("access granted")
else:
print("access denied")
I needed this for my calculator, tyvm!
My first thought is using any() methods but I guess this is more simple and accurate
No need to use a mutable list here.. use a tuple (unmutable), better performances on the long run
@@farhanaditya2647 in this exemple, no it will not, but when you teach something, it's important not to teach also bad practices, even if it is a small mistake. Otherwise, beginners could get use to this bad practices.
@@WexyR then you want to use a frozenset saved somewhere else outside of the if statement.
i was just making a little practice game and ran into that problem. thanks for the help man
For someone who doesn’t code in python my first instinct is to assume the first one is valid syntax.
Use a set over a list, for constant access time.
It's a bit confusing but actually make sense when you take into account wanting empty value to evaluate to false.
The other on "False" or Boolean("False") are both evaluated as True.
Saw the problem right away but didn't thoughy of this answer, even knowing the prob you still learn new and efficient ways to do it and that's cool
This is one of the reasons I like strongly typed languages, like c#, a lot more. The compiler already points out such errors for you.
one thing that was confusing is when he first told you the corrected code he said you can fix it by "name equals bob or if name equals tom etc" but he doesnt actually type that out on screen. I understood what was happening but I wonder how many people this would just confuse. it would
If name == 'Bob' or name == 'Tom' or name == 'Mike'
which is really wordy and effectively the same logic as the if name in ['a','b','c'] because that statement is effecitveley doing a truth check against the name value and every item in list.
I've just started learning Python and I keep making this mistake. Glad to see that's why it does it the way it does, in retrospect it makes sense it evaluates the other two as true
Everyone is fighting about static or dynamic typing in C/Python, but a beginner can’t make a mistake like this when you can’t use a string where a Boolean goes.
so.. you created a new list and searched in it only once just to avoid writing if name == 'a' or name == ''b'' or name == 'c'
Use a set for membership tests, not a list. Sets are O(1); lists are O(n).
“if name in” is more pythonic, but this behavior is really just a general programming concept. . Conditional statements are entirely separate from one another, but the lack of required parentheses in Python makes it harder to spot. If you wrote it in js, for example, like “if (name == “Chris” || “Tom” || “Mike”) it’s easier to spot the problem.
I knew that output but dude that's a perfect example of showing where people mess up!
The thing is, this quirk appears in other languages, but with a slight change of conventions. Java for example allows objects without any comparison to act as boolean values in conditional statements, so the standard is that null objects are always considered false. That's how I could guess
I thought i was the only one using synthwave 84 without the glowing effect
Cracking good mate. Keep on with the videos.
I’m by no means experienced with programming, but I would’ve never thought the first option even has a chance to work lmao
@@farhanaditya2647 it just looks wrong
To save memory use a tuple for the list of names ;)
You need name == before every string in the if statement, not just the first one
Even better way to make set rather than list so that in operator can do it in o(1) time...
strings having truth values is such a nightmare lol
Just go
if name != "Chris":
print("acess granted"
else:
print("Acess denied")
Besides this always use immutables for access , permission etc
"Access Granted" looks like some order of operations shenanigans happening in the conditional.
If you have use instead of a list a tuple, it would evaluate faster
yes
if name in (blah, blah, blah)
You can replace 'or' with 'and'
Then it would be an array wouldn’t it? I come from C based programming languages but I am pretty sure every language has pretty much (if not) the same variable system