0

Help with Text String Code

Here's the code: Here's the problem: "IndexError: list index out of range." Can anyone explain why this is happening? I feel like it's a minor detail I'm overlooking, but if it's big and ugly, don't hesitate to call me out. As always, thanks in advance. questions = [ "We don't serve strings around here. Are you a string?" "What is said on Father's Day in the forest?" "What makes the sound 'Sis! Boom! Bah?'" ] answers = [ "An exploding sheep." "No, I'm a frayed knot." "'Pop!' goes the weasel." ] q_a = ((0,1), (1,2), (2,0)) for q, a in q_a: print("Q:", questions[q]) print("A:", answers[a]) print()

8th Apr 2020, 7:20 PM
deepspaceghost
deepspaceghost - avatar
2 Antworten
+ 4
You just need to separate the elements of the lists with comma
8th Apr 2020, 7:35 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Thanks, Santa! I figured it was something minor I wasn't paying attention to.
8th Apr 2020, 7:50 PM
deepspaceghost
deepspaceghost - avatar