0
What is wrong in this??? This is the code for conversion of upper to lower and vice versa without using inbuilt function
str=input() char=input() for i in range(len(str)): if (char>64) and (char<91): char=char+32 print(char) elif (char>96) and (char<123): char=char-32 print(char) if char==32: print(" ") print(str)
7 Answers
+ 6
Disha Jain ,
there are several issues in the code:
âȘïžyou are using variable 'char' for comparing against upper or lower, this is not correct
âȘïžin the for loop you get the individual characters of the string in the variable 'i'.
âȘïžuse 'i' after converting it to the ascii value by using ord() for the comparison
=> so the code has to be reworked
happy coding and good success!
+ 4
This will help you:
https://code.sololearn.com/c7dKOAm8Hpc3/?ref=app
+ 4
chr() and ord() are inbuilt functions. I don't think you can do it without them.
+ 3
my code is close to the ones of JaScript, but it handles and keeps characters like punctuation:
https://code.sololearn.com/c7RpPWEfFfsV/?ref=app
0
Sololearn-------input
sOLOLEARN---- output
0
Hi Disha!
Here is my code by using characters instead of numbers.
https://code.sololearn.com/cZFPxxYjLY46/?ref=app
0
Disha Jain Here are three possibilities, with only one meeting your needs:
https://code.sololearn.com/cGPK0m7w9meI/?ref=app
# Hope this helps