mardi 6 juin 2017

Can someone help me work out this error

This is my code, it is writen in python version 2.7.13:

import random
num=random.sample(range(1,9),4)
print(num)
thing=1
while thing==1:
    while thing==1:
        Usernum=str(input("Input a number of four DIFFRENT digits all of which are between 1 and 9 or exit"))
        if Usernum = "exit":
            print("Goodbye")
            break
        else:
            pass
        if len(set(Usernum)) == 4:
            pass
        else:
            print("You enterd a number that wasn't 4 digits, please try again!")
            thing==1
            pass

        if Usernum.isdigit:
            pass
        else:
            print("you entered something that isnt a number, please try again!")
            pass
        num1,num2,num3,num4 = Usernum.split() 
        if num1 in (num2,num3,nub4) or num2 in (num3,num4) or num3=num4:
            print("you ented a number with duplicate digits, Please try again!")
        else:
            break
else:
pass

When I run it I get a syntax error, why? It says: invalid syntax: random sample.py, line 26, pos 67 in file /Users/soldenh/OneDrive - Bryanston School/Bryanston Work/ICT/code library/random sample.py, line 26 Before i was getting a diffrent error which said : "ValueError: need more than 1 value to unpack"

Aucun commentaire:

Enregistrer un commentaire