Apr-29-2020, 09:48 PM
Hey everyone, this is my first post so I hope this is clear.
I am working on some code where the user is asked to select from a comboBox.
This problem I have is the code is suggesting I need to include the self argument however when I include it, it still errors out. I've gone around in circles for a couple of days now. Your insights would be greatly appreciated.
WITHOUT SELF ARGUMENT
-Muzzrooms
I am working on some code where the user is asked to select from a comboBox.
This problem I have is the code is suggesting I need to include the self argument however when I include it, it still errors out. I've gone around in circles for a couple of days now. Your insights would be greatly appreciated.
WITHOUT SELF ARGUMENT
def play(self): guess = str(self.ui.comboBox.currentText()) return guess if play() == comp_num: winmessage() else: losemessage()And this is the Error
Error:Traceback (most recent call last):
File "D:/Muzzrooms/Desktop/Year 11/Term 2/Digital Solutions/Guessing Game/Guessing_game_completed.py", line 15, in <module>
class MainWindow:
File "D:/Muzzrooms/Desktop/Year 11/Term 2/Digital Solutions/Guessing Game/Guessing_game_completed.py", line 43, in MainWindow
if play() == comp_num:
TypeError: play() missing 1 required positional argument: 'self'
WITH SELF ARGUMENTdef play(self): guess = str(self.ui.comboBox.currentText()) return guess if play(self) == comp_num: winmessage() else: losemessage()And this is the error I receive if I include the self argument.
Error:Traceback (most recent call last):
File "D:/Muzzrooms/Desktop/Year 11/Term 2/Digital Solutions/Guessing Game/Guessing_game_completed.py", line 15, in <module>
class MainWindow:
File "D:/Muzzrooms/Desktop/Year 11/Term 2/Digital Solutions/Guessing Game/Guessing_game_completed.py", line 43, in MainWindow
if play(self) == comp_num:
NameError: name 'self' is not defined
Your help is greatly appreciated;-Muzzrooms