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

17th Dec 2017, 10:22 PM
NIMA
NIMA - avatar
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
17th Dec 2017, 10:46 PM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Or something along this line: print(*(chr(i) for i in range(33, 127)))
18th Dec 2017, 5:01 AM
David Ashton
David Ashton - avatar
+ 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.
18th Dec 2017, 8:01 AM
H Chiang
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
18th Dec 2017, 12:10 AM
H Chiang