+ 1

Input:Python output: pYTHON

how to solve it friends ?

28th Sep 2017, 7:02 AM
Ganesh Aleti
Ganesh Aleti - avatar
8 odpowiedzi
28th Sep 2017, 7:27 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 7
yeah @Ekansh, #Ruby is smart!
29th Sep 2017, 7:41 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 6
or ... b=input() print(b[0].lower()+b[1:].upper())
28th Sep 2017, 7:35 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 4
inp = input() text = "" for l in inp: if l.isupper(): text += l.lower() else: text += l.upper() print(text)
28th Sep 2017, 7:19 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Or a simple 1 liner: [print(l.lower(), end="") if l.isupper() else print(l.upper(), end='') for l in input()]
28th Sep 2017, 7:29 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
@Nomeh your code just makes the first character lowercase and the rest uppercase. I think what was wanted was for the case to be flipped. uppercase characters become lowercase and lowercase to uppercase.
28th Sep 2017, 7:40 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
#Ruby puts gets.swapcase
29th Sep 2017, 7:26 AM
Ekansh
0
Mr.Dawg! thanks :)
28th Sep 2017, 7:27 AM
Ganesh Aleti
Ganesh Aleti - avatar