Python Forum
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
int() ValueError
#1
Very simple chunk of code:

ip = input("Enter #:")
ip = int(ip)
If I enter 2.3, why do I get:
ValueError: invalid literal for int() with base 10: '2.3'

If int() accepts a string or a float, why does it not handle this value by truncating?
Reply


Messages In This Thread
int() ValueError - by kcunning - Oct-11-2017, 09:41 AM
RE: int() ValueError - by j.crater - Oct-11-2017, 10:11 AM

Forum Jump:

User Panel Messages

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