Jul-02-2018, 11:43 AM
(Jul-02-2018, 03:51 AM)Zombie_Programming Wrote: A way to solve this is to get rid of theipt.split(" ")
and change yourint(input(...))
toeval(input(...))
like I do here,
Using eval() on user input is a really bad thing. A user could enter code, for example, to delete all the files on your drive!
You are currently trying to apply int() directly to input() return string, but as you have a string with two 'numbers' in it with a space between, that will cause an error.
the ipt.split() method returns a list of strings. You have to convert each string to an integer.
Try this:
ipt = input("Pythagorean theorem, Enter sides A and B and I will solve for C\n") a, b = [int(x) for x in ipt.split(" ")]which uses list comprehension to step through each element in the list of strings from the split() method and covert it to an integer, leaving a list of integers in place of the list of strings. The assignment unpacks the two entries to a and b.
I am trying to help you, really, even if it doesn't always seem that way