Codeskulptor报语法错误Bad Token "",Python3代码问题排查(已自行解决)
Hey there! Let's break down what was causing that frustrating invalid token error in your CodeSkulptor code, plus share the fixed version that works as intended.
The Root Issue
The error came directly from this line:
random.seed(1,10)
In standard Python 3 (and CodeSkulptor's Python environment), the random.seed() function only accepts one positional argument for the seed value (there's an optional keyword-only parameter for seed version, but it only accepts 1 or 2—definitely not 10). Passing two integers here didn't match the function's expected signature, which triggered the invalid token warning. It looks like you might have mixed up the seed function with randint() (which does take a range of two numbers)—super easy mistake to make!
Corrected Code
Here's the polished, error-free version of your multiplication quiz:
import random random.seed(1) # Only pass a single seed value, or remove this line for non-repeatable randoms a = random.randint(1, 10) b = random.randint(1, 10) print("What is: " + str(a) + " X " + str(b) + "?") ans = int(input("Your answer: ")) if a * b == ans: print("Correct!") else: print("Incorrect!")
A quick style tip: In Python, you don't need parentheses around the condition in the if statement—they work perfectly fine without, but feel free to keep them if that's your preferred coding style.
内容的提问来源于stack exchange,提问作者Vlogging Gabes

