TypeError Too many Arguments

后端 未结 4 1848
自闭症患者
自闭症患者 2021-01-23 03:29

When running this code it appears with an error that there are too many arguments in line 8. I\'m unsure on how to fix it.

#Defining a function to raise the firs         


        
4条回答
  •  悲&欢浪女
    2021-01-23 03:52

    The issue is that the python input() function was only ready to accept one parameter - the prompt string, but you passed in three. To solve this issue, you just need to combine all three pieces into one.

    You can use the % operator to format string:

    y = int(input("What power would you like to raise %d to?\n" %x,))
    

    Or use the new way:

    y = int(input("What power would you like to raise {0} to?\n".format(x)))
    

    You can find the document here.

提交回复
热议问题