Python Codes The Series -1 ©Photo by wiki commons Not only in Python but also in the day-to-day life, the letters in English alphabets are characterized into two cases viz. upper case and lower case. Our first program will be a general fun program for the beginners. In this program, we will learn to swap the cases of the letters of English alphabets being entered by the user with the help of a few lines of Python code. For example: If the user enters: " hoLa AmIGo" , the python program would convert this string into " HOlA aMigO" . The Program is noted below: string=input("Enter a string :") length=len(string) s='' for i in range(length): if string[i].islower(): s=s+string[i].upper() elif string[i].isupper(): s=s+string[i].lower() else: s=s+string[i] print(s) FOR QUICK REFERENCE: The len() function gives the length of the string and the the input() function takes input from the user. Hope you like i...
SGPYTHON gives you the whole concept about Python from scratch to Expert level. Codes, programs and Python related theory topics are included and usually updated on this website.