-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmembership_operators.py
More file actions
55 lines (40 loc) · 1.18 KB
/
Copy pathmembership_operators.py
File metadata and controls
55 lines (40 loc) · 1.18 KB
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, dictionary)
# 1. in
# 2. not in
word = "APPLE"
letter = input("Guess a letter in the secrete word: ")
if letter in word:
print(f"There is a {letter}")
else:
print(f"{letter} was not found")
if letter not in word:
print(f"{letter} was not found")
else:
print(f"There is a {letter}")
print()
students = {"kim", "park", "yoo"}
student = input("Enter the name of the student: ")
if student in students:
print(f"{student} is a student")
else:
print(f"{student} was not found")
print()
user = {
"name": "janghun",
"age": 23,
"is_student": True
}
info = input("Enter user info: ")
if info in user: # dictionary에서 in은 key를 검사
print(f"{info} is a key of user")
print(f"the value is: {user.get(info)}")
else:
print(f"{info} is not a key of user")
print()
email = "yoojanghun@naver.com"
if "@" in email and "." in email:
print("Valid Email")
else:
print("Invalid Email")