python - Function is not getting called -


i have below code have 2 functions print_menu() , pstockname()

def print_menu():     print ("\t\t\t\t 1. stock series ")   print ("\t\t\t\t 2. invoke stocks.") print ("\t\t\t\t 3. generate dc stock list . ") print ("\t\t\t\t 4. quit")   def pstockname():     global stocklist, fstocklist     pstocklist = []     fstocklist = []     stocklist = str(raw_input('enter pipe separated list of stocks : ')).upper().strip()     items = stocklist.split("|")     count = len(items)     print  'total distint stock count : ', count     items = list(set(stocklist.split("|")))     # pipelst = stocklist.split('|')     # pipelst = [i.split('-mc')[0] in stocklist.split('|')]     # pipelst = [i.replace('-mc','').replace('-mc','').replace('$','').replace('^','') in stocklist.split('|')]     pipelst = [i.replace('-mc', '').replace('-mc', '').replace('$', '').replace('^', '') in items]     # pipelst = [stock.rsplit('-mc',1)[0] stock in pipelst]     filepath = '/location/stock_data.txt'     f = open(filepath, 'r')     lns in f:         split_pipe = lns.split(':', 1)         if split_pipe[0] in pipelst:             index = pipelst.index(split_pipe[0])             pstocklist = split_pipe[0] + "|"             fstocklist.append(pstocklist)             del pipelst[index]     # f.close()     lns in pipelst:         print bcolors.red + lns, ' wrong stock name' + bcolors.endc         if lns:             uresp = str(raw_input('do want continue option 0 [yes|y|no|n] : ')).upper().strip()             if uresp == "no" or uresp == "n":                 os.system("tput clear")                 print bcolors.fail + "\n please use option 0 enter stock names before proceeding." + bcolors.endc                 # stocklist = none                 print_menu()         else:             pstockname()     f.close() 

in above code must seeing in 4th last line calling print_menu() function. printing content of print_menu() function not doing operation , going pstockname() function. follow operation want execute print_menu() function when calling it:

while choice >= 1 , choice < 4:     if choice == 4:         os.system("tput clear")          if stocklist:             uresp = str(raw_input(                 bcolors.fail + 'do need move : ' + stocklist + ' ? press y go main menu , n quit [yes|y|no|n] : ')).upper()             if uresp == "no" or uresp == "n":                 print  bcolors.header + "goodbye." + bcolors.endc                 break 

i mean when calling print_menu() function in pstockname() function in 4th last line pstockname() function should print content of print_menu() function , when press 4 should perform operation quit. when pressing of option 1 4 going pstockname() function only.

please me doing wrong here.

i'm bit new here, not see assign keyboard input variable "choice". therefore, program not recognize end user input is. suggestion assign "choice" raw_input so:

choice = raw_input() if choice == "4": # alternatively, perform int(choice) == 4    print ("yes") 

i hope helps!


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -