18  Data Types

18.1 Task : Return changed size strings

18.2 Task : Return string parts

  • File datatypes.py
#This function will receive as an input a string and return the same string in uppercase.
def myupper(str):
    return str.upper()

#This function will receive as an input a string and return the same string in lowercase.
def mylower(str):
    return str.lower()

#This function will receive as an input a string and if the string is in uppercase, it will return the same string as lowercase. If the string is in lowercase it will return the same string in uppercase.
def invertsizing(str):
    if(str.lower() == str):
        return str.upper()
    else:
        return str.lower() 
     
def stringpart(st,n):
    return st[0 : n]