(Solved):Python Problem: Two variables, x and y, supposedly hold strings of digits. Write code that converts these to integers and assigns a variable z to the sum of these two integers. Make sure that if ei… View Answer…

 

Question

Python problem: Two variables, x and y, supposedly hold strings of digits. Write code that converts these to integers and assigns a variable z to the sum of these two integers. Make sure that if either x or y has bad data (that is, not a string of digits), z will be assigned the value of -1.

 

EXPERT ANSWER

The code below is divided into two parts: the “try” block and the

Scroll to top