+ 2

Please help me to get rid of this problem. [Python]

I want to assign a variable with all ascii character(33-126) in a string.I wrote this code but its not work. for i in range(33, 127): a = f'{chr(i), end = ""}' So, can you help me? Please.

16th Mar 2019, 3:49 PM
Abdul S Ansari
Abdul S Ansari - avatar
4 ответов
+ 5
You're constantly reassingning the value of "a". You should instead add those characters to "a". a = "" for i in range(33, 127): a += chr(i)
16th Mar 2019, 3:58 PM
Diego
Diego - avatar
+ 5
You can also use a comprehension and the .join() method a = "".join(chr(i) for i in range (33, 127))
18th Mar 2019, 3:01 AM
David Ashton
David Ashton - avatar
+ 1
Diego Thank you so much.
16th Mar 2019, 4:00 PM
Abdul S Ansari
Abdul S Ansari - avatar
0
What next should are do at this moment ,
14th Apr 2019, 11:28 PM
Zemo.sunday