Hi I can't find another question that answers this because it is really basic. I'm learning python and my current code will have to be copy and pasted for every letter of the alphabet. Instead how can I use find()
and ord()
for a range/A-Z.
This is my code at the moment:
A = (ord("A")-64)*(file.find("a"))
if A < 0:
A = 0
B = (ord("B")-64)*(file.find("b"))
if B < 0:
B = 0
C = (ord("C")-64)*(file.find("c"))
if C < 0:
C = 0
print(A+B+C)
I want to do this all the way to Z but there must be a way to do that without copying and pasting.
If you can help, thank you so much. I've tried file.find("a","b"...)
but this wouldn't work.