Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with my program
#1
This is supposed to be the outcome of my code
Output:
Enter your choice: 3 Enter the value of the base followed by the exponent: 5 3 The power of 5 raised to 3 is 125.
my code is
n,exp=int(input("Enter the value of the base:")).split(",")
      def power(n,exp):
         if(exp==1):
            return(n)
         if(exp!=1):
           return(n*power(n,exp-1))
print("The power of",n, "raised to",exp,"is",power(n,exp))
This is the error i receive
Error:
Traceback (most recent call last): File "C:\Users\NICKLAUS\Desktop\LE3222_RosalesNicklaus.py", line 1, in <module> n,exp=int(input("Enter the value of the base:")).split(",") ValueError: invalid literal for int() with base 10: '3,5'
Reply


Messages In This Thread
Need help with my program - by zeclipse21 - Dec-08-2019, 06:27 AM
RE: Need help with my program - by ibreeden - Dec-08-2019, 10:19 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020