Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with my program
#2
If you have such an error in a compound statement, you must split it to see where exactly the error arises. The message tells you the error is in:
n,exp=int(input("Enter the value of the base:")).split(",")
The first part to be executed will be:
input("Enter the value of the base:")
When you enter the string: '3,5', this will be replaced with '3,5' in the next stage:
>>> int('3,5')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '3,5'
This gives you the answer: '3,5' is not an integer. int() expects one parameter, so the most readable construction would be to split the line into:
n,exp=input("Enter the value of the base:").split(",")
n = int(n)
exp = int(exp)
The most
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