I am making a dice rolling program where you try to have a dice roll higher than the computer, although it is completely randomized. I have the function:
def wait(loop, time):
sleep(time)
for number in range(loop):
print('.')
sleep(time)
That is inteded to cause a ... appear for waiting.
Sample input:
wait(3, 1)
Intended output:
.
.
.
Where it loops 3 times, and waits 1 second between each loop. I am getting the error
TypeError: 'str' object is not callable
I don't understand because it is a number not a string.
I have tried using int() on every part and only some parts For example:
def wait(loop, time):
sleep(int(time))
for number in range(int(loop)):
print('.')
sleep(int(time))
wait(int(3), int(1))
and
def wait(loop, time):
sleep(int(time))
for number in range(int(loop)):
print('.')
sleep(int(time))
wait(3, 1)
and
def wait(loop, time):
sleep(time)
for number in range(loop):
print('.')
sleep(time)
wait(int(3), int(1))
Because you assign a string value to wait
this creates a local variable which over-rides the function with a name of wait
wait = input('\nPress enter to begin the game:')
You can't then call wait(3,1)
later because '\nPress enter to begin the game:'(3,1)
doesn't make sense.