i wrote this code:
`
def key_gen(l):
lettersi = ()
for a in range(l[0], l[4]):
letters1 = lettersi + (a,)
for b in range(l[5], l[9]):
letters2 = lettersi + (b,)
for c in range(l[10], l[14]):
letters3 = lettersi + (c,)
for d in range(l[15], l[19]):
letters4 = lettersi + (d,)
for e in range(l[20], l[24]):
letters5 = lettersi + (e,)
key = letters1 + letter2+ letter3 + letters4 + letters5
return key
`
i run it and while im on the python shell...:
letters = ('A','B','C','D','E','F', 'G','H','I','J', ' ', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Z', '.')
>>>key_gen(letters)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in key_gen
TypeError: 'str' object cannot be interpreted as an integer
I dont know what mistake im making here because im a beginner in python but i want the output to be like this. Do you have any idea how to fix it?
>>>key_gen(letters)
((‘A’, ‘B’, ‘C’, ‘D’, ‘E’), (‘F’, ‘G’, ‘H’, ‘I’, ‘J’), (‘ ’, ‘L’, ‘M’, ‘N’, ‘O’), (‘P’, ‘Q’, ‘R’, ‘S’, ‘T’), (‘U’, ‘V’, ‘X’, ‘Z’, ‘.’))
maybe the function i defined cannot read tuples of strings but i dont know how to do that and ive already googled it and couldnt find anything.