-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifproject.py
More file actions
executable file
·35 lines (22 loc) · 958 Bytes
/
Copy pathifproject.py
File metadata and controls
executable file
·35 lines (22 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /usr/bin/env python3
import random
### Asks for an integer between 6 and 8. Returns error if a string is input ###
try:
answer1 = int(input("what is an integer between 6 and 8?:"))
except:
print("invalid string input")
if answer1 == 7:
print("Correct!")
else:
print("Incorrect!")
### Asks for an integer and rolls n simulated dice using the random library. Returns error if string is input ###
try:
diceroll = int(input("How many dice do you want to roll?:"))
except:
print("invalid string input")
dicelist = [] ##Future list for dice declared outside of while loop
while diceroll != 0:
dice = random.randint(1,6) ## Rolls the dice
dicelist.append(dice) ## Appends current diceroll to the dicelist
print(f"You rolled a {dice}!") ## Prints the current diceroll
diceroll -= 1 ## Decrements the diceroll by 1