Using tuple/lists and functions - Raspberry Pi Forums
i trying write python3 code following. there 7 different functions defined. user input define multiple numerical entries of numbers between 1 , 7. of varying length, example, end list of numbers between 1 , 7 - 1,4,2,3,5,6,1,2.... , on.
list, want call corresponding function, first number 1 call function1, 4, function4 etc.
list of functions fixed @ seven, thought using tuples define list of functions, call function tuple.
didn't far. acctup tuple. hoping see 'action0()' appear when code run, instead 'none'
couple of questions.
why none, print command?
looking @ bigger picture, best/easiest method want achieve?
thanks,
cj
list, want call corresponding function, first number 1 call function1, 4, function4 etc.
list of functions fixed @ seven, thought using tuples define list of functions, call function tuple.
didn't far.
code: select all
def action0(): print ('this action0') def action1(): print ('this action1') acttup=action0(),action1() print (acttup[0])
couple of questions.
why none, print command?
looking @ bigger picture, best/easiest method want achieve?
thanks,
cj
code: select all
acttup=action0(),action1()
code: select all
acttup=action0,action1
maybe
code: select all
print( acctup[0]() )
raspberrypi
Comments
Post a Comment