Jump to content
Stef's Coding Community

picot

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About picot

  • Rank
    New member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. 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
  2. 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!
  3. 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
  4. 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.
×
×
  • Create New...