0
Is it possible to set a letter to a variable and have it go through the rest if the alphabet by any means? (Explained better inside)
Im still pretty new to python, but I think this would be good practice. Im wanting to write a poem for my SO using python but wanted to somehow assign the letters to integers and use (+1/ -1 or something like it) to make it go through the alphabet and spell out the words of the poem. I may not have explained this very well but if anyone thinks they could help it would be appreciated!
3 Antworten
+ 1
# look at the existing relationships here http://www.asciitable.com/
# and pythons inbuilt methods for conversion between the
# represenations using chr and ord
print([chr(x) for x in range(97,123)])
print([ord(x) for x in 'abcdefghijklmnopqrstuvwxyz'])
# you may want to read about the concepts of encoding schemes
# ASCII,Unicode as a starting point it may help clarify
# the issue. You may find this helpful as a starting point
'''
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/
'''
# if you just want to fiddle about with the idea
# look at the effects individually
print(ord('a'))
print(chr(97))
# good luck
0
Thats exactly what i was looking for! Like I said, im still pretty new to python so i hadnt come across those functions yet, but i will definitely be messing around with it to see if I get the desired results. Thanks a bunch!