a= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' n = '' res = '' key = 1 enter = input('').strip() def add (f): if f != '': f = int(f) f += key f = str(f) return f else: return n for i in enter: if a.count(i) == 0: if i.isnumeric(): n += i else: n = add(n) res += nn= '' res += i else: n = add(n) res += n n = '' res += a([(a.index(i)+key)%len(a)]) n = add(n) res += nn ='' print(res) 

I do not know how to fix the error in the line:

 res += a([(a.index(i)+key)%len(a)]) 

Gives an error message:

 Traceback (most recent call last): File "F:/PYCHARM PROGRAm/1/venv/Scripts/1333213213213.py", line 29, in <module> res += a([(a.index(i)+key)%len(a)]) TypeError: 'str' object is not callable 

PS A little of the essence of the program is Caesar's encoder. When I enter abc11, it should output bcd12. That is + 1 character / number.

  • res + = a [(a.index (i) + key)% len (a)] There are no need for parentheses after a, this is not a function. - Kirill Malyshev

1 answer 1

 a= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' n = '' res = '' key = 1 enter = input('').strip() abc11 def add (f): if f != '': f = int(f) f += key f = str(f) return f else: return n for i,z in enumerate(enter): if a.count(z) == 0: if z.isnumeric(): n += z else: n = add(n) res += n n= '' res += z else: n = add(n) res += n n = '' res += a[(a.index(z)+key)%len(a)] n = add(n) res += n n ='' print(res) bcd12 
  • for i, z in enumerate (enter): What does i do in this line, since it is not used anywhere, and does not work without it? And so BIG TO YOU thank you brother) Very much helped out) - mlook8008