jeudi 20 août 2020

I'm making a word guessing program but it is showing the error that def is an invalid syntax [closed]

I'm a beginner and i came across this error: When i run the program it shows def as an invalid syntax please help me debug this error def is a built-in statement so it shouldn't show any error but there shouldn't be any other way aroun Here is my code:

import random
ques=random.randint(1,100)
l1=['a','b','c','d']

def multiple(x):
    m=randomint(1,x)
    multi=x*m
    print(multi,"is a multiple of the number")

def divisible(x):
    l2=[]
    for i in range(1,x):
        if x%i==0:
            l2.append(i)
    print("the number is divisible by", random.choice(l2)

def greater(x):
    print("the number is greater than", random.randint(1,ques)

def smaller(x):
    print("the number is smaller than", random.randint(ques+1,100)


while True:
    ans=int(input('enter your guess'))
    if ans==ques:
        print('You guessed correct')
        break
    else:
        hint=random.choice(l1)
        if hint='a':
            multiple(ques)
        if hint='b':
            divisible(ques)
        if hint='c':
            greater(ques)
        if hint='d':
            samaller(ques)



Aucun commentaire:

Enregistrer un commentaire