Note: I am using Python 3.5 I just started creating a part two to a text based game I made, and here is the code I'm having trouble with:
import random
def game():
randomIp = random.randint(10, 999)
def tutorial():
global randomIp
print('Hello.')
print(randomIp + '.' + randomIp + '.' + randomIp + '.' + randomIp)
The problem that kept coming up was:
File "C:\Users\Anony\Desktop\SICCr4k2BrokeFold\SICCr4k2Broke.py", line 18, in tutorial
print(randomIp + '.' + randomIp + '.' + randomIp + '.' + randomIp)
NameError: name 'randomIp' is not defined
I don't know what's up. I have the global put into tutorial()
and it doesn't have an error for saying randomIp
isn't defined in the command global randomIP
only for print(randomIp + '.' + randomIp + '.' + randomIp + '.' + randomIp)
. Does anyone know what the problem is? And if I wanted a different random number to be printed after each "."
. What would the code be for that? I would like it so that it would print out something like 23.321.43.23
. A completely different number after each period.