Why do i get 'valueerror: invalid literal for int() with base 10' in python?

Example:

x = int('a')

You're trying to convert a non-numeric string to an integer.

Solution:

Ensure the string represents a valid number before converting.


x = int('5')
print(x)

Beginner's Guide to Python