-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfaces.py
73 lines (53 loc) · 1.5 KB
/
faces.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
############################################
# #
# by : Ali Sharify #
# Dont copy currently Code #
# Github: alisharifyy #
# #
############################################
"""
This is simple version
"""
import sys
def main():
# get input from user
user = input()
#iterate to each charactor
for i in range(len(user)):
if (user[i] == ":"):
# get corecctly char with + 1 to function
tmp = user[i] + user[i+1]
convert(tmp)
continue
if (user[i] in [")","("]):
continue
else:
print(user[i],end="")
# orint new line
print()
# defind convertor function of emojies
def convert(inp):
if (inp == ":)"):
print("🙂",end="")
elif (inp == ":("):
print("🙁",end="")
main()
# this is a better version of program using regex
"""
x = input("")
import re
def better_version(input):
# this function using regex for find :) and :( from text
if not input:
return "empty input"
# regex for find all :) in str
regex_smile_face = ":\)"
# replace all str via regex
result = re.sub(regex_smile_face,"🙂",input)
# regex for find all :( in str
regex_sad_face = ":\("
# replace all str via regex
result = re.sub(regex_sad_face,"🙁",result)
return (result)
print(better_version(x))
"""