I want to only find the values in the list which are strings, and change them to upper case.
If lst
is not a list I want to return -1
.
For the below example, the output should be: [11, 'TEST', 3.14, 'CASE']
.
lst = [11, 'TeSt', 3.14, 'cAsE']
def upper_strings(lst):
if type(lst)!= list:
lst = -1
else:
for char in lst:
if type(char) == str:
char=char.upper()
else:
char == char
return lst
print(upper_strings(lst))
The output that I got was:
[11, 'TeSt', 3.14, 'cAsE']