Skip to main content
added 94 characters in body
Source Link

I wrote this dice game as beginner practice. This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')

(Edit: Thanks for all the help! I still don't fully understand the syntax, but I'll learn)

I wrote this dice game as beginner practice. This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')

I wrote this dice game as beginner practice. This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')

(Edit: Thanks for all the help! I still don't fully understand the syntax, but I'll learn)

Became Hot Network Question
edited tags
Link
toolic
  • 18k
  • 6
  • 31
  • 239
Move question body above code to improve the preview.
Source Link
Peilonrayz
  • 44.7k
  • 7
  • 80
  • 158

I wrote this dice game as beginner practice. This is working code, shown here:but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')

This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

I wrote this dice game as beginner practice, shown here:

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')

This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

I wrote this dice game as beginner practice. This is working code, but I would like to improve it by adding more functions. Though, since I am still a beginner, I don't know how, so help would be appreciated!

import random

print('Time to go gambling! Press ctrl + enter, or RUN (the big red button), to roll!')
dice = random.randint (1,20)
print(str(dice))
count = 1
while dice != 20:
  dice = random.randint (1,20)
  print(str(dice))
  count +=1
if count == 1:
  print('It took you ' + str(count) + ' try to get a 20... average.')
else:
  print('It took you ' + str(count) + ' tries to get a 20... embarrassing.')
deleted 5 characters in body
Source Link
Loading
Source Link
Loading