0
Why the code does not working ?
I want to print equivalent characters of 0 to 20 why this code does not working ? https://code.sololearn.com/c4lg1AajarFz/?ref=app
4 Answers
+ 7
Your only outputing the char value of 0, 21 times. 0 doesn't have a visible character. Nor do any values up to 20. Check against an ascii table:
http://www.asciitable.com
You can try something like:
count = 97 # a
while count <= 122: # z
print (chr(count))
count = count + 1
+ 4
Or something along this line:
print(*(chr(i) for i in range(33, 127)))
+ 1
Just read your question again.
And the others are correct, that you donât need the variable âaâ, just cast the counter to char. However not all characters are printable, hence I believe what David is saying , any char less than 33 might not behave as expected.
0
I agree with ChaoticDawg
I would try something like:
count=0
a = 97 # a
while count <= 25: # z
print (chr(count+a))
count = count + 1
print (count) ## always add print lines near questionable code so you can visually see what is happening