Lower & upper (2) X86558


Statement
 

pdf   zip

html

The statement is exactly the same as problem X23315: write a function lowupp(info) that expects to receive a string; if it starts with the character ’^’, then it returns the rest of the string in upper case; if it starts with the character ’_’, then it returns the rest of the string in lower case; if it starts anyhow else, it returns the string unchanged.

The little difference is the following: in case you solved X23315 using the method startswith() from the class str, now you are requested not to use it, nor any other method from str beyond, of course, upper(), lower(), and indexing. Be careful with limit cases!

Sample session
>>> lowupp('_Hi There!')
'hi there!'
>>> lowupp('^Hi There!')
'HI THERE!'
>>> lowupp('Hi There!')
'Hi There!'
Information
Author
José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python