This is, of course, just an example, and you will have to tell us what input you are giving for us to be able to say for sure what the issue is. ValueError: invalid literal for int() with base 10: '- 1'Īdding a space between the - and 1 will cause the string not to be parsed correctly into a number. This could be caused by a lot of things, for example: > int(input("Type a number: ")) Your problem is that whatever you are typing is can't be converted into a number. Since 3.0, Python will also automatically convert integers to floats if you divide them, so it's actually very easy to work with.) Previous guess at answer before we had the traceback: (As a note, Python is pretty good at abstracting this away from you, most other language also have double precision floating point numbers, for instance, but you don't need to worry about that. You need to use the right one based on what you require. Integers, which store whole numbers (ℤ), and floating point numbers, which store real numbers (ℝ). ValueError: invalid literal for int() with base 10: '0.3'Ĭomputers store numbers in a variety of different ways. If int(a) > int(input("Type a number: ")) I wrote a program to solve y = a^x and then project it on a graph.
0 Comments
Leave a Reply. |