-
Notifications
You must be signed in to change notification settings - Fork 1
/
6.8.py
45 lines (39 loc) · 990 Bytes
/
6.8.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
"""
COMP.CS.100 Week Chapter
Name: Shamsur Raza Chowdhury <shamsurraza.chowdhury@tuni.fi>
Student Number: 050359798
This program does something
"""
def isthereComma(str):
"""
checks if there is any comma in the string if yes return true
"""
for val in str:
if val == ",":
return True
def reverse_name(string):
""""
this is the function that reverses the name
"""
if string=='':
return string
elif string==",":
return ''
elif isthereComma(string):
x=string.split(",")
lastName = x[0]
firstName = x[1]
lastNameStrip= lastName.strip()
firstNameStrip= firstName.strip()
if firstNameStrip=="":
return f"{lastNameStrip}"
elif lastNameStrip=="":
return f"{firstNameStrip}"
else:
return f"{firstNameStrip} {lastNameStrip}"
else:
return string
def main():
pass
if __name__ == "__main__":
main()