Ask coding questions

← Back to all posts
Coding Assignment Problem
VedantDagar (0)

Program should generate 4 random numbers from 1-9 as the "Secret Code."
User should be prompted for their guess of those four numbers.
After they provide their full guess, the user is told how many are correct.
As long as the user does not get all four correct, they keep getting asked for their guess.
After the user finally gets all four numbers correct, they are congratulated and then told how many tries it took them.

This is the requirements, my code is not fully functioning and is skipping the whole code up to the else code which states, none of your numbers were correct try again.

Comments
hotnewtop
NeilBhaduri (65)

numbers = list()

for i in range (4):
num = random.randint(1,9)
numbers.append(num)

I am not too good with showing code, but that is my best. Also, I think the braces '[ ]' tell the computer that it is a set. And if you mean it to be a list, change that. That is my best advice.

VedantDagar (0)

@NeilBhaduri Thank you for this, I had used this in my code and added a few extra things as well.