-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Downloads
Gallery
Store
Posts posted by picot
-
-
thank you for your quick response. my attempt was as you suggested both to exclude 6, and print add the sum of the rolled numbers as well...
if a != 6: print(sum(a)) else: print ("you lose, your score for this last round = 0")
but print(sum(a)) doesn't seem right .. how do I add a number to a variable. many thanks! -
if not too much trouble please help me with one last question. I watched a youtube tutorial on how to make a dice game and I can not find anything on the internet to what I wanted to do. in my case I just used a single die:
import random a = random.randint(1, 6) print(a)
I know how to add each roll/result into a list but I wanted to ask how to add all the random rolls to the previous one? say 6 could be a game breaker (game ends if 6 is rolled and game resets to 0) otherwise, every roll adds to the last roll? thank you for your help advance -
I appreciate it! thank you!
-
I wanted to ask how you can find the first digit after decimal point on python from a user input. for example if user inputs 1.299999 I want to find ''2'' please help. thank you.
finding first digit after decimal
in Python
Posted
a = random.randint(1, 6) if a != 6: print(sum(a)) else: print ("you lose, your score for this last round = 0")
in the above code, my attempt was to roll a single die, which will give a different number from 1 to 6 each time the program is run. I want to add those numbers each time its run (unless it's number 6, then the added numbers/scores reset)
say for example, I run the program and I rolled the number 2, then I run the program again and roll 5, I was hoping the program to show the sum of the two separate rolls as '7' adding the separate runs... and if I roll a third time and get '1' it adds to the last score 7 to get an 8 and so on, (until a 6 is rolled in the random dice game ,,which breaks all the loop and the score will be 0)