I am writing a code that takes in a tuple of integer as intervals and outputs a range of alphabets. I could use some help on return statement.
>>> arrangement((5, 3, 11, 7))
'A-E F-H I-S T-Z'
Below is what I have written so far. The return statement seems to return only the last iteration of the loop:
def arrangement(numerical_representation):
interval = ''
step = 65
for integer in numerical_representation:
interval = chr(step) + '-' + chr(step + integer - 1)
step += integer
return interval
>>> arrangement((5, 3, 11, 7))
'T-Z'
With print statements I am able to go through all the iteration, but I can't seem to make them print in a single line with quotation marks on both ends.
def arrangement(numerical_representation):
interval = ''
step = 65
for integer in numerical_representation:
interval = chr(step) + '-' + chr(step + integer - 1)
step += integer
print(interval)
>>> arrangement((5, 3, 11, 7))
A-E
F-H
I-S
T-Z
How should I proceed?