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.

code: select all

def action0():     print ('this action0')      def action1():     print ('this action1')  acttup=action0(),action1()     print (acttup[0]) 
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

code: select all

acttup=action0(),action1()   
action0() call function. want reference:

code: select all

acttup=action0,action1
not sure how call these functions, though.
maybe

code: select all

print( acctup[0]() )


raspberrypi



Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code