0

For s in `sololearn`?

s = `sololearn` for i in s: [print(i if("a" < i) else 0, end=")] OUPUT: solole0rn #How are they mixing letters as references? #assuming "i" is every character in the string "sololearn", how am I to know what character is represented by "a"? If they said "replace l with zero, I would understand but how are they arriving at this? Thanks for any help.

12th Apr 2019, 10:03 PM
tristach605
tristach605 - avatar
2 Réponses
0
When comparing strings the maximum is the one with the highest ASCII value. All letters from b to z have higher ASCII values than the letter a. Therefore, the condition "a"<i holds true for them. The only exception is "a"<"a", which is False. That's why a 0 is printed instead of the letter a.
12th Apr 2019, 10:30 PM
Diego
Diego - avatar
0
Thanks Diego! I guess I havent gotten to the ASCII portion of Sololearn yet, so I'll google it now.
14th Apr 2019, 1:40 AM
tristach605
tristach605 - avatar