What is wrong in this??? This is the code for conversion of upper to lower and vice versa without using inbuilt function | Sololearn: Learn to code for FREE!

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)

8/2/2021 2:59:12 PM

Disha Jain

7 Answers

New Answer

+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