AngusOld
AngusOld

Reputation: 43

Keeping a running total of score in python 3

I am writing a program that rolls two dice; and then according to what is rolled, points are assigned; and a running total is kept. So far, I have this; but I keep running into an error of "int is not callable". Can someone please help?

import random
def dice():
    a = 1
    b = 6
    return random.randint(a,b)
rollOne = int(dice())
rollTwo = int(dice())


def greeting():
    option = input('Enter Y if you would like to roll the dice: ')
    if option == 'Y':
       print('You have rolled a' , rollOne, 'and a' , rollTwo)
       points = []

       if rollOne() == rollTwo():

           points.append(10)

           print('You have a total of %d points' % (sum(points)))

       if rollOne == 6 or rollTwo ==6:

           points.append(4)

           print('You have a total of %d points' % (sum(points)))

       if (rollOne + rollTwo) == 7:

           points.append(2)

           print('You have a total of %d points' % (sum(points)))

dice()
greeting()

Upvotes: 0

Views: 1016

Answers (2)

DavidG
DavidG

Reputation: 25370

The result from dice() is an integer which you have named rollOne and rollTwo.

They cannot be "called" like you have tried to do rollOne().

In order to solve the error, remove the brackets from the line (which you have done in your other if statements)

if rollOne() == rollTwo(): 

becomes

if rollOne == rollTwo: 

Upvotes: 1

Sandeep Lade
Sandeep Lade

Reputation: 1943

Problem is in this ,

   if rollOne() == rollTwo():

rollone and rolltwo are return values not functions

Upvotes: 0

Related Questions