While doing some list comprehension exercises, i accidentally did the code below. This ended up printing True/False for all 16 entries on the list.
threes_and_fives =[x % 3 == 0 or x % 5 == 0 for x in range(16)]
print threes_and_fives
After i played with it i was able to get the outcome that I wanted, where it printed the numbers from that list that are divisible by 3 or 5.
threes_and_fives =[x for x in range(16) if x % 3 == 0 or x % 5 == 0]
print threes_and_fives
My questions is why did the first code evaluated to true or false and the other one didn't? I'm trying to get a grasp of python so the more explanations the better :) Thanks!