0

Syntax error with defining a variable (python)

With the attached code I get a syntax error on the def time() point info at the closing parentheses. Can someone explain the issue import random import time def time() b = 0 var1 = random.randint(800,900) while a < var1: print(time.time) b = b + 1 amount = input() x = 0 while x = 0: time() amount = amount - 1 if amount == 0: x = 0

15th Nov 2021, 9:05 PM
Curtis Chase
Curtis Chase - avatar
3 Antworten
+ 2
There is a missing colon after def time().
16th Nov 2021, 3:46 AM
Brian
Brian - avatar
0
Variable a in time() is not defined. Also check your while-loop: the condition needs to be x == ? and it needs an exit condition
15th Nov 2021, 9:11 PM
Lisa
Lisa - avatar
0
Lisa I figured it out with your help. Both if those were issues but i was still having some so i rewrote the code i think the same way im not positive and it didnt work but i realized i had imported time when i swapped the variable name and it worked
15th Nov 2021, 9:22 PM
Curtis Chase
Curtis Chase - avatar