'Printing a random response from a list
I'm trying to create a 8ball game and when i have it send out the random response after the user inputs their question it just sends in the terminal a-z (alphabet) for each response.
Code:
if number == "4":
eightball = input("8ball the best enraging game there is!\nQuestion: ")
print(f"Answer: {random.choice(eightball)}")
List:
eightball = [
"I can agree.",
"Uhm, negative.",
"Hell yeah.",
"No i disagree.",
"I'd change my mind...",
"Weird question dude.",
"Im goinging to pretend you did not ask that.",
"At times sure.",
"Sometimes sure.",
"I would ask someone other than me.",
"Little personal dont you think?",
"Yes.",
"No."
]
Terminal/Console:
Number: 4
8ball the best enraging game there is!
Question: I am smart
Answer: t
There will be a Photo of the terminal below, just to clarify there isn't any errors.
Solution 1:[1]
Fix: I named all my variables eightball, causing them to interfere. So i changed the list name to a different name.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Derek |

