简体   繁体   中英

Python TypeError: int() takes at most 2 arguments (3 given)

I am trying to write a simple hangman game in python but is getting this error. Not sure where the error is coming from. I appreciate any help. Thank you.

TypeError                                 Traceback (most recent call last)
<ipython-input-1-323840294aea> in <module>
      8 seconds = 60
      9 
---> 10 class engine(seconds):
     11         import getpass
     12         word=getpass.getpass("please enter a secret word")

TypeError: int() takes at most 2 arguments (3 given)

Code:

You have a global int variable named seconds that you are attempting to derive your classes from. I suspect you intended them to be functions, which requires def not class , eg:

def engine(seconds):

However, you also have multiple classes/functions named the same thing so you will also need to resolve that.

You don't need to use classes for that. Instead, use def keyword and define the function with the seconds parameter. You are trying to derive a class from an integer.

Also, you have 2 engine "classes". The second definition will overwrite the first one. So you will have to change that.

def engine(seconds)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM