get the list and input from one function and run them in different function

Posted by rookie on Stack Overflow See other posts from Stack Overflow or by rookie
Published on 2013-10-30T21:50:47Z Indexed on 2013/10/30 21:53 UTC
Read the original article Hit count: 176

Filed under:

i have a programm that generate the list and then i ask them to tell me what they want to do from the menu and this is where my problem start i was able to get the input form the user to different function but when i try to use the if else condition it doesn't check, below are my code

def menu(x,l):
    print (x)
    if x == 1:
        return make_table(l)
    if x == 2:
        y= input("enter a row (as a number) or a column (as an uppercase letter")
        if y in [ "1",'2','3']:
            print("Minmum is:",minimum(y,l))
    if x== 3:
        print ('bye')

def main():
    bad_filename = True
    l =[]
    while bad_filename == True:
        try:
            filename = input("Enter the filename: ")
            fp = open(filename, "r")
            for f_line in fp:
                f_str=f_line.strip()
                f_str=f_str.split(',')
                for unit_str in f_str:
                    unit=float(unit_str)
                    l.append(unit)
            bad_filename = False
        except IOError:
            print("Error: The file was not found: ", filename)
        #print(l)
    condition=True

    while condition==True:
        print('1- open\n','2- maximum')
        x=input("Enter the choice")
        menu(x,l)

main()

from the bottom function i can get list and i can get the user input and i can get the data and move it in second function but it wont work after that.thank you

© Stack Overflow or respective owner

Related posts about python