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()

I'd start by changing your input() function to a different name to prevent confusion.
Add an else to catch any other input that isn't 1 or 2. There is also an infinite loop here. Not sure what version of python you're using but the newer versions for the print function needs () so like print("hello world") rather than print "hello world". Not sure if any of these things were actually your problem but if they are not feel free to send me your error output and I can help you out :)

This article has been dead for over six months. Start a new discussion instead.