+ 2

Why my code isnt appending list with uppercase letters?

https://code.sololearn.com/c0mScfwRay8E/?ref=app

21st Apr 2020, 6:27 AM
Albert
Albert - avatar
10 Antworten
0
if u mean like this s = len(x) while c < s: u can do that
21st Apr 2020, 6:41 AM
durian
durian - avatar
+ 1
Thanks for your suggestion now i have solved the problem
21st Apr 2020, 6:42 AM
Albert
Albert - avatar
+ 1
You can use list comprehension and just append it to itself x = ['ab','bc','cd','de'] x += [i.upper() for i in x] print(x) Basically the same as: x = ['ab','bc','cd','de'] y = [] for i in x: y.append(i.upper()) x += y print(x)
21st Apr 2020, 8:01 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks BroFar
21st Apr 2020, 8:18 AM
Albert
Albert - avatar
+ 1
Welcome Albert
21st Apr 2020, 8:19 AM
BroFar
BroFar - avatar
0
that code probably would run forever u append it to the original list, and that while loop's condition will never turn false u can create another list to hold that new uppercast words
21st Apr 2020, 6:36 AM
durian
durian - avatar
0
What if i will assign len to another variable before using while loop ?
21st Apr 2020, 6:40 AM
Albert
Albert - avatar
0
Hi there
22nd Apr 2020, 2:25 PM
Blessed Allan Lugolobi
Blessed Allan Lugolobi - avatar