-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathif.py
More file actions
24 lines (18 loc) · 639 Bytes
/
if.py
File metadata and controls
24 lines (18 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# A brief look at for loops, if/else statements, and the 'in' keyword in Python
numbers = [0,1,2,3,4,5,6,7,8,9]
for number in numbers:
if number < 5:
print("This number is less than 5")
else:
print("This number is greater than 5")
#Ok so let's look at the 'in' keyword
magic_numbers = [3, 9]
user_number = 4
for number in magic_numbers:
if user_number == magic_numbers:
print("This number is in this list")
else:
print("This number is not in this list")
#We can even simplify it even more:
user_number in magic_numbers
#this would return False, because, it's not in magic_numbers...duh