Oct-15-2017, 05:59 AM
import random
## create a list initilizae
surverylist=[]
no_of_participant=2
def checkqn(qn,surveydata): # should i do this instead?-> def checkqn(qn)
if qn==1:
Name=raw_input("What is your name:")
surveydata['name']=Name
elif qn==2:
Age=raw_input("What is your Age:")
surveydata['age']=Age
i=1
print ("no_of_participant %s" %str(i+1))
surveydata={}
checkqn(1) #should i do this instead? checkqn(1,surveydata)
checkqn(2,surveydata)
surverylist.append(surveydata)
Questions
I am not sure how dict pass value to a function
Should i pass arg with the dict to a function?
checkqn(1) or checkqn(1,surveydata)
## create a list initilizae
surverylist=[]
no_of_participant=2
def checkqn(qn,surveydata): # should i do this instead?-> def checkqn(qn)
if qn==1:
Name=raw_input("What is your name:")
surveydata['name']=Name
elif qn==2:
Age=raw_input("What is your Age:")
surveydata['age']=Age
i=1
print ("no_of_participant %s" %str(i+1))
surveydata={}
checkqn(1) #should i do this instead? checkqn(1,surveydata)
checkqn(2,surveydata)
surverylist.append(surveydata)
Questions
I am not sure how dict pass value to a function
Should i pass arg with the dict to a function?
checkqn(1) or checkqn(1,surveydata)