-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path26.py
55 lines (36 loc) · 961 Bytes
/
26.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#Membership operators = used to test whether a value or variable is found in a sequence
#(string, list, tuple, set, or dictionary)
#1. in
#2. not in
#EXAMPLE 1
word = "SHAYEN"
letter = input("Guess a letter in the secret word: ")
if letter in word:
print(f"There is a {letter}")
else:
print(f"{letter} was not found")
#EXAMPLE 2
students = {"Shayen", "Thomas", "Sherin"}
student = input("Enter the name of a student: ")
if student in students:
print(f"{student} is in this class")
else:
print(f"{student} is NOT in this class")
#EXAMPLE 3
grades = {
"Shayen": 'A',
"Thomas": 'B',
"Sherin": 'C',
"Antony": 'D'
}
student = input("Enter the name of a student: ")
if student in grades:
print(f"{student}'s grade is {grades[student]}.")
else:
print(f"{student} is not in the dictionary")
#EXAMPLE 4
email = "shayen@gmail.com"
if "@" in email and "." in email:
print("Valid email")
else:
print("Invalid email")