-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample29.py
More file actions
56 lines (47 loc) · 996 Bytes
/
example29.py
File metadata and controls
56 lines (47 loc) · 996 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
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
56
"""
a_number = input("bir sayi giriniz: ")
if a_number.isnumeric():
a_number = int(a_number)
else:
print("hatali giris yaptiniz")
# exit()
try:
a_number = int(a_number)
except :
a_number = input("hatali giris yaptiniz, lutfen bir sayi giriniz: ")
a_number = int(a_number)
"""
nums = [65, 27, "-", 48, 95, "-", 78, 96, 100]
total = 0
len = len(nums)
for num in nums:
try:
total += num
except TypeError:
len -= 1
avg = total / len
print(avg)
test_cases = [
"username@companyname.com",
"", "usernamecompanyname.com",
"username@companynamecom",
"user name@companyname.com"
]
"""
for test in test_cases:
index = test.find("@")
if index != -1:
user_name = test[0:index]
else:
user_name = ""
print(user_name)
"""
test = "usernamecompanyname.com"
for i, t in enumerate(test):
if t == "@":
index = i
try:
user_name = test[0:index]
except NameError:
user_name = ""
print(user_name)