python 3.x - int variable increment from function -


i trying input user assign 'faction' , based on following inputs modify values curadvrep\curcrmrep.

the input shows indise funtion desired result, need able permanently modify rep faction.

from file 2 called in file 1:

curadvrep = 0 curcrmrep = 0 crimson = "crimson brootherhood reputation: {0}".format(curcrmrep) advent = "advent of chaos reputation: {0}".format(curadvrep) pathseldict = {'advent' : advent, 'crimson' : crimson, 'n' : n, 'c' : cont, 'd' : d, 'p' : p, 'l' : l}  def faction (rep):     global curadvrep     global curcrmrep     global advent     global crimson      if rep in pathseldict:         if rep == 'advent':             curadvrep += 50             curcrmrep -= 5             advent = "advent of chaos reputation: {0}".format(curadvrep)             print(advent)             #print(factions[joinworld])         elif rep == 'crimson':             curadvrep -= 5             curcrmrep += 50             print(pathseldict[joinworld])     else:         print(dismiss)         sys.exit(0) 

from file 1:

rep = input("which side on? advent or crimson? ").title() questfunc.faction(rep) print(advent) print(curadvrep) print(curcrmrep) 

output:

 pick box or leave alone? (p or l): p pick box reputation gain advent of chaos reputation: 5 side on? advent or crimson? advent advent of chaos reputation: 55 advent of chaos reputation: 0 0 0 

i sorry if either question or code offensive. have researched answer question, due either not finding matching answer or inability translate indirect answer specific question, haven't found solution.

so found work around. have asked question , had no helpful response, please take look.

choice1 = input(" pick box or leave alone? (p or l): ").lower() repgain(choice1) print(advent, curadvrep)   # function gain  def repgain (choice):     global curadvrep     global curcrmrep     global advent     global crimson      if choice in pathseldict:         if choice == 'p':             print('reputation gain\nadvent + 100')             curadvrep += 100             return curadvrep         elif choice == 'l':             print('crimson + 100')             curcrmrep += 100             return curcrmrep          else:             print(dismiss)             sys.exit(0)  output: reputation gain advent + 100 advent of chaos reputation: 100 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -