String | swap case | HackerRank | Python

preview_player
Показать описание
This video is about the swap case problem from HackerRank.
For 1 : 1 Tutoring
WhatsApp contact : 7278222619

Follow us on:
Whatsapp:
Telegram:

Facebook:

Linkedin:

Instagram:

#HackerRank #String #Python
Рекомендации по теме
Комментарии
Автор

def swap_case(s):
x = ""
for i in s:
if i.isupper():
x += i.lower()
else:
x += i.upper()
return x
Without using join method we do that bro

reddybhumi
Автор

i went with this
def swap(n):
sw = n.swapcase()
return sw

somukdutta
Автор

thankyou for explaining so clearly bro

ayushchoudhary
Автор

def swap_case(s):
a = ''
for i in s:
if i.islower():
a+=i.upper()
elif i.isupper():
a+=i.lower()
else:
a+=i
return a

gauravmishra
Автор

what would be the solution of an in place change - i tried to work with the indexes but i got: TypeError: 'str' object does not support item assignment

helikopter
Автор

Sir, Why we took empty string x="" Is there any other way without using x

babag
Автор

for i in range(s):
if i.islower():
s.upper(i)
else:
s.lower(i)
what is wrong in this...

pujithagaddale
Автор

So many aman in the comment section lol! 😳

gamerx.
Автор

instead of all these code we can use swap_case method

jaiste
Автор

everyone stop it!
just add this after return
s.swapcase()
just it why people make it complex idk -_-
s.swapcase() will covert uppercase into lowercase that's it

fdkeltg