+2

Why am I getting the following error? ValueError: could not convert string to float:

#Comparing two rectangles R_1_L = float( input("Please enter the length of Rectangle 1: ") ) R_1_W = float( input("Please enter the weidth of Rectangle 1: ") ) R_2_L = float( input("Please enter the length of Rectangle 2: ") ) R_2_W = float( input("Please enter the weidth of Rectangle 2: ") ) R_1_A = R_1_L * R_1_W R_2_A = R_2_L * R_2_W if R_1_A > R_2_A: print("R 1 is bigger than R 2") elif R_1_A < R_2_A: print("R 2 is bigger than R 1") else: print("R 1 is equal to R 2") Please enter the length of Rectangle 1: Traceback (most recent call last): File "..\Playground\", line 3, in <module> R_1_L = float( input("Please enter the length of Rectangle 1: ") ) ValueError: could not convert string to float:

6/28/2019 8:18:25 PM

Samad Sunny

1 Answer

New Answer

+4

I've tried your code. It works if you enter four numbers in a row, separated by line breaks. Sample input: 54 32 45 98