-
Notifications
You must be signed in to change notification settings - Fork 8
/
sWAP cASE.py
44 lines (25 loc) · 862 Bytes
/
sWAP cASE.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
# You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.
# For Example:
# Www.HackerRank.com → wWW.hACKERrANK.COM
# Pythonist 2 → pYTHONIST 2
# Input Format
# A single line containing a string .
# Constraints
# Output Format
# Print the modified string .
# Sample Input 0
# HackerRank.com presents "Pythonist 2".
# Sample Output 0
# hACKERrANK.COM PRESENTS "pYTHONIST 2".
def swap_case(s):
new = ""
for i in range(0,len(s)):
if(s[i].isupper()):
new += s[i].lower()
elif(s[i].islower):
new += s[i].upper()
return(new)
if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)