Im having a main function issue. My program is a text analyzer of more than several lines and then input 'END' to stop taking input. It analyzes input text based on the chosen options 1 through 2, relooping for invalid choice. Im having an issue having it properly work in the main function. Here is what I have:
def input():
line = ""
twodimensional = []
while line != "END":
line = raw_input("")
if (line != "END"):
new_line = ""
for char in line:
if char.isalpha():
new_line += char
else:
new_line += " "
line_list = new_line.split()
twodimensional.append(line_list)
return twodimensional
def longWord(twodimensional):
twodimensional = input()
entire_list = []
for line in twodimensional:
for word in line:
entire_list.append((word.lower()))
return max(entire_list, key=len).split()
def shortWord():
twodimensional = input()
entire_list = []
for line in twodimensional:
for word in line:
entire_list.append((word.lower()))
return min(entire_list, key=len).split()
def menu():
print
print "You get to choose what you want to do to your text.\n\n"
print "1) Longest word"
print "2) Shortest word"
def main():
input()
menu()
menu_choice = raw_input("Which option do you choose? ")
while True:
if menu_choice == '1':
print longWord()
elif menu_choice == '2':
print shortWord()
menu()
menu_choice = input("Which option do you choose? ")
main()