0

I am making a program that analyzes text from a user

After inputting several line and using the keyword "DONE", the program will ask for one of 8 possible options which is the menu() function where the user will enter the number. How would i be able to run my program using main() function to where the user will be able to enter a choice have the text analyzed according to my functions and then be prompted again until they choose to quit the program. Also a choice of numbers under 1 or greater than 8 must not work for the menu. I know its alot but im stuck!

#DONE indicates the end of input
def input():
line = ""
dl = []
while line != "DONE":
line = raw_input("")
if (line != "DONE"):
nl = ""
for char in line:
if char.isalpha():
nl += char
else:
nl += " "


ll = nl.split()
dl.append(ll)
return dl

def long():
dl = input()
zz = []
for line in dl:
for word in line:
zz.append(word)
print max(zz, key=len)

def short():
dl = input()
zz = []
for line in dl:
for word in line:
zz.append(word)
print min(zz, key=len)


def common():
dl = input()
zz = []
for line in dl:
for word in line:
zz.append(word)
distinct_words = []
counter = []
for word in zz:
if word not in distinct_words:
distinct_words.append(word)
counter.append(1)
else:
index = distinct_words.index(word)
counter[index] += 1
print distinct_words
print counter

return 0

def fL():
dl = input()
single_list = []
for i in range (0,len(dl)):
single_list = single_list + dl[i]
char_list = []
for word in single_list:
char_list.append(str(word[0])
print char_list

def last():
dl = input()
single_list = []
for line in dl:
single_list.append((line[-1]))
print single_list

def total():
dl = input()
zz = []
for line in dl:
for word in line:
zz.append(word)
wordcount = len(zz)
print wordcount	

def trd():
dl = input()
zz = []
for line in dl:
for word in line:
zz.append(word)
twords = zz[2::3]
print twords
def quit_program():
print "END"
quit()


def menu():
print
print "Choose an option"
print "1. Longest word"
print "2. Shortest word"
print "3. Most common word"
print "4. First let of each word"
print "5. Last word of each line"
print "6. Total words"
print "7. Third words"
print "8. End Program"

def main():
main()
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by JoshuaBurleson
0

issues:

-input is a BIF

-fix your indentation

-think about it; how would you use the functions on anything? That should help you use them in the main() function

-I'm sure there are more but I don't feel like analyzing this whole thing with the indentation all messed up, it's a pain to read.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.