Hack Forums
[Python] Russian Roulette - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Russian Roulette (/showthread.php?tid=5049346)



Russian Roulette - Baba Yaga - Nov 7, 2015

Hi guys! I always visit this forum because it is a great place to find project ideas and to learn some new things. Thought I would share a little script I made, it's a Russian Roulette script that asks the user for input, and if it is equal to the deadly number, then it just prints out a simple 'You lose.' I've coded something similar in PHP, except if you lose all the files on the server get deleted 🎉

Hope you guys like this script

Code
from random import randint

turns = 0 #counter for your number of turns

while turns != 5: #sets how many turns you get
    deadly_num = randint(0,9) #generates random number
    user_num = int(raw_input('Please input a number: ')) #user input #

    print user_num
    print deadly_num

    #print 'The number of turns is %d' % turns

    if user_num == deadly_num:
        print 'You lose'
        break
    turns = turns + 1
else:
    print 'You survived'



* - gungunfebrianza - Nov 8, 2015

thanks for sharing, added to my collection of python script :)