Python Drunken Man Game


 Video Link:- 




Source Code:- 

import random

size = 60  
x = input("Enter a letter to begin :- ")
position = size/2
while(True):
    print("|START|",end = "")
    for i in range(size):
        if (i==position):
            print(x,end="")
        else:
            print(" ",end="")

    print("|FINISH|")
    move = random.randint(-1,1)   # +1, 0 , -1
    position = position + move
    if (position<1):
        print("OOPS !! You Lost")
        break
    if (position>size-1):
        print("CONGO!! YOU WON")
        break

No comments:

Post a Comment