0

I want to do a little random game between system and user. I need help or idea on how to write the code in python.

The system and user will start with 100 point each. The system will produce 1 random number from 1 to 6 and the user will input two, if any of the numbers the user inputted is not equal the number picked by the system, 10 point is removed from the points of the user and add to the systems point if equal 20 is removed from the system and added to the user. When either the user or the system reach 0 the game print game over or you win and ask if to start again. And this time the user will be inputting and the system predicting at random. I wrote the code but its not working well. p1 = 100 p2 = 100 while True: print("You have " + str(p1) + " points") print("Computer have " + str(p2) + " points") a = int(input("Enter 1st num: ")) b = int(input("Enter 2nd num: ")) com = rnd.randint(1, 6) print("computer Entered\n " + str(com)) if com != a or b: p1 -= 20 p2 += 20 else: p1 += 10 p2 -= 10 if p1 >= 200: b

9th Jan 2019, 4:45 AM
Victor Asagba
Victor Asagba - avatar
3 ответов
+ 1
Victor Asagba , as you described your game I think the if statement should be like this: if com == a or com == b: p1 += 20 p2 -=20 else: p1 -= 10 p2 -= 10
9th Jan 2019, 10:10 PM
Sekiro
Sekiro - avatar
+ 1
It seems you already planned everything so you just need to start write the code then if you get stuck somewhere you can ask for help... but first you should try do it by yourself! besides in wich language you plan to do it?
9th Jan 2019, 11:13 AM
Sekiro
Sekiro - avatar