![]() |
error message with module - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: error message with module (/thread-16824.html) |
error message with module - Pepper887 - Mar-16-2019 Hello, I am trying to make a dice game. I came across an error and I cannot figure out what is happening. Could someone explain this error? Everything in the dice game is working except this part. Here is the code. from die import Die
RE: error message with module - snippsat - Mar-16-2019 die most be your filename die.py ,an Die is a class or function. Example: # die.py import random def dice_toss(): return random.randint(1, 6)Use: λ ptpython >>> from die import dice_toss >>> dice_toss() 4 >>> dice_toss() 4 >>> dice_toss() 6 >>> dice_toss() 2 RE: error message with module - Pepper887 - Mar-16-2019 Thank you so much for helping me. I have a new error now. My program shows me that their is an error with this line. Also, I am trying to implement two players, one of which is the computer. Is this the correct way of doing this? I will also post the code after the error. if val == 'unrolled': val = -1 if (val >= 1 and val <= self.sides) or val == -1: self._value = va player1 = player1dice player2 = player2dice
RE: error message with module - Yoriz - Mar-16-2019 if val == 'unrolled': val = -1 # no code after the :there shouldn't be any code after the : val = -1 should be moved to the next line Use 4 spaces for indents. if val == 'unrolled': val = -1 if (val >= 1 and val <= self.sides) or val == -1: self._value = va # should this be va or val? player1 = player1dice player2 = player2diceDo these assignments on separate lines player1 = player1dice player2 = player2dice |