I want to save the output of the line print(LettersUpC[CodeNum])
into a variable outside, but have it be a different variable each time. How can I accomplish this?
while 1 == 1: CodeWord = str(input("Code-word: ")) Stop = ["Stop", "Exit", "End", "Terminate"] if CodeWord in Stop: exit("User Terminate") while CodeNum < 55: if CodeWord == CodeWordsUpC[CodeNum]: print(LettersUpC[CodeNum]) break else: CodeNum = CodeNum + 1
Advertisement
Answer
this is a modified version that will work.
output = [":", ] RTs = 0 InOrOut = str(input("Encode or Decode, E/D: ")) if InOrOut == "D": while RTs < 9: CodeNum = 0 CodeWord = str(input("Code-word: ")) Stop = ["Stop", "Exit", "End", "Terminate"] if CodeWord in Stop: break while CodeNum < 55: if CodeWord == CodeWordsUpC[CodeNum]: output.append(LettersUpC[CodeNum]) break else: CodeNum = CodeNum + 1 RTs = RTs + 1 print(str(output[1] + output[2] + output[3] + output[4] + output[5] + output[6] + output[7] + output[8])) """This you might want to change to more depending on the amount of code-words you want to traselate"""