two values in a variable python

So I'm pretty sure this is not allowed, but I'd really like to know why you can do this in python and what purpose it would serve...  Shouldn't it ERROR out?

I posted too much to the python forums for my class for the day.  Got a little to happy about sharing.
Bringing it here so I don't forget, and if someone can explain it to me, I'll come back and update this with what it means.


car = 30 and True # this only holds the True value I think
truck = 30 or False #this only holds the 30 value I think
#efficient = True
#cars = 30
#trucks = 30
roads = 'T' and 'F'

print(f" {roads[0]}") #what the heck is going on here?
# a zero in here produces F, but a 1 errors out.
print(f" {car} {truck}")

Comments

Popular posts from this blog

Statistics, Python, Making a Stem Plot

Pandas Python and a little probability

JavaScript Ascii animation with while loops and console.log