0

I recently started trying to learn python, and found this small dice program online:

import random

min = 1
max = 6

roll_again = 'yes'

while roll_again == 'yes' or roll_again == 'y':
    print ('rolling the dices...')
    print ('The values are...')
    print random.randint(min, max)
    print random.randint(min, max)

    roll_again = raw_input('Roll the dice again?')

However, when trying to execute the program i get a syntax error on the first print random.randint(min, max) line, saying it's an invalid syntax. I've looked around online for answers, but I haven't been able to find any solutions. I'd appreciate any help.

  • 1
    You are using Python 3, the program you found is in Python 2. Just put parantheses around the call to `random.randint` and you should be fine. Oh, and rename `raw_input` to `input`. – L3viathan Jan 11 '20 at 14:08
  • Does this answer your question? [random.random invalid syntax](https://stackoverflow.com/questions/32977276/random-random-invalid-syntax) – benbotto Jan 11 '20 at 14:10
  • Alright, I inserted the parentheses around `random.randint()` and renamed `raw_input` to `input`, and it worked! Thanks! – coolmage Jan 11 '20 at 14:22

1 Answers1

0

It's python 3. you should use parenthesis for the print statement.