0

I'm trying to write a text file that has a list of rearranged alphabets so that each begins with a different character. The first letter is moved to the end, repeat.

    alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

    # generate 26 alpabets without typing all
    def alpha_gen(alphabet,a_list):
       x = 0
       while x < 26:
           alphabet += [alphabet.pop(0)]
           key = alphabet(0)
           written = str(key) + ' : ' + str(alphabet) + '\n'
           a_list.write(written)
           x += 1

    def main():
       a_list = open('alpabet_list.txt', 'w')
       alpha_gen(alphabet, a_list)
       a_list.close()

    if __name__ == '__main__': main()

But I get this error:

    File "vigenere_cipher.py", line 13, in alpha_gen
    key = alphabet(0)
    TypeError: 'list' object is not callable

closed as off-topic by random May 14 '16 at 23:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about computer hardware or software, within the scope defined in the help center." – random
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Also, this question belongs on Stack Overflow, not on Super User :) – gogeccc May 14 '16 at 23:04
0
File "vigenere_cipher.py", line 13, in alpha_gen
key = alphabet(0)
TypeError: 'list' object is not callable

In Python, () indicate that you want to call (execute) some function. What you are doing in line 13 with alphabet(0) is trying to call alphabet which is a list, not a function. Change it to alphabet[0] to access first element of alphabet list.

Not the answer you're looking for? Browse other questions tagged or ask your own question.