0
Problems with python random module
i have a program that randomly selects a name from a list of names and asks the selected person some questions. how do i tell the program to associate the randomly chosen name to the question. E.g if chris was the chosen name how do i associate his name with his question. this also applies to other names. and finally i would like to enclose this in a loop and also print the most reoccurring answers from different people at the end.
5 Answers
+ 7
#I assume you mean something like this
import random
namelist=["chris","zyra","sona"]
name= random.choice(namelist)
question="what's your favorite color"
print(question,name,"?")
+ 7
add to it in what way? theres lots of ways depending on what you mean.
like
name="prince"
print("what the heck do you mean, %s?" % name)
or
name="princess"
list=["so",name,"wanna go out on a date with me?"]
print(" ".join(list))
0
yes but for some reason it doesn't seem to work
0
but i dont wanna make the question a variable i just wanna add the name to the question
0
Ahri thanks problem sorted out