I'm trying to verify is a list of numbers i choose has in all elements diferent numbers. I set a flag variable true if all values in list were diferent and false otherwise. However my function is returning zero and not true or false. I know i inicialize my flag variable at zero because i needed to defined that same variable at the start of the function
i already came up with a code but my function is returning zero. My for sentence is not beeing iterated
v=[]
def creat_function():
v=[int(input('digit a number\n')) for j in range(0,int(input('number of elements\n')))]
return v
print(creat_function())
def diferences(v):
flag=0
for j in range(0,len(v)):
if v[j-1]!=v[j]:
flag=True
else:
flag=False
return flag
print(diferences(v))
Aucun commentaire:
Enregistrer un commentaire