I’m trying to create a variable that is a string that includes a random number, but it keeps telling me that my syntax is invalid, highlighting the r in rand.
import random as rand
Smoke = str(rand.randint(20, 40)" Smoke Shells")
What mistake have I made here?
>Solution :
There are a few things wrong in the code, like you shouldn’t convert a string to a string
str(" Smoke Shells")
and you can’t add a string to an int.
This should work, though:
import random as rand
Smoke = str(rand.randint(20, 40)) + " Smoke Shells"