Skip to content
Sign upLog in

Not Sure Why This isn't working?

Profile icon
1Dagree

Its not completed but it just keeps repeating same thing and i did not program it to do that can someone help

You are viewing a single comment. View All
Profile icon
[deleted]

what does it keep repeating? please provide more context. it looks like it runs fine to me...

Profile icon
LizFoster

@sugarfi
he means that, no matter what you enter, it'll only ever say
"You are a civillian
Your number is 4
Who do you think the mafia is (1-4):"

Profile icon
[deleted]

@LizFoster
that is just the random function though - if you choose a number 1-4, 1, 2, and 3 are much more likely, and come up almost all the time. The reason it always prints Your number is 4 is because he wrote print("Your number is 4"). It repeats because it is in a while loop. There is nothing going wrong there...

Profile icon
LizFoster

@sugarfi
Yes, exactly. I am not saying that the code does something it's not made to do, I was simply clarifying what he was asking for.

Profile icon
1Dagree

@sugarfi
the code isn't fully completed yet but the problem is that if you are the most voted (4) then dead should equal true and the game ends but that doesn't happen even if 4 is the most voted (the variable you) it just asks you who the mafia is again. Instead of saying you died and the mafia wins that is the problem.

Profile icon
[deleted]

@Uzalii
i did get voted though, and i died...

Profile icon
1Dagree

@sugarfi
i tried it and i am still not getting killed. How did you manage to die?

Profile icon
[deleted]

@Uzalii
again, the random module. It is just not very likely to die.