Reputation: 3
I'm trying to do a simple music player. I want ask some questions to the user while he is listening the music.
In next lines, if the user doesn't want to listen again to the music, I will add a list of music and make him choose, and, in the future, I want put some commands for skip to the next music and something about that.
P1 = str(input('wanna again? (Y/N)'))
def DEF1():
if P1 == ('Y'):
P2 = str(input('do you know what is it? (Y/N)'))
if P2 == ('Y'):
P3 = str(input('what is it?'))
print(P3)
if P2 == ('N'):
print('this is a game sound!')
if P1 == ('N'):
print('that is it')
def DEF2():
while:
playsound.playsound('', True) #a music link
if __name__ == '__main_':
Process(target=DEF1).start()
Process(target=DEF2).start()
The thing is: i want to start two process (DEF1 and DEF2) at the same time , it's a 'while' and a 'if' function, DEF1 it's some questions that i want to do for the user of the program, and DEF2 it's a music that repeat if the 'while
Upvotes: 0
Views: 115
Reputation: 91
If I'm understanding correctly and you want your second method to play another sound or song based on the value of P3, you need to return a value from DEF1 based on user selection.
So in addition to 'print(P3)', you want to include 'return P3'.
Then you call DEF1 from within DEF2, assigning the return to a variable, for example:
song = DEF1()
The variable 'song' then holds the value of the answer to the question: 'what is it?'
What this does is allow DEF2 to call DEF1 with all of the questions and answers.
DEF2 then uses the return from DEF1 to determine which song to play. So instead of a while statement, you probably want an if statement (your while statement wouldn't have worked anyway since it doesn't have a condition for the loop).
Now when you call DEF2, DEF2 in turn, will call DEF1 for you.
Upvotes: 1