+ 1
Whatâs wrong with my code?!?!?
Iâm trying to do the balconies challenge and itâs accepting the code for test case 1 and 5 but not for 2-4. I canât figure out why. Can somebody help please ? apt_a =input().split() apt_b = input().split() def area(dim): res = 1 for x in dim: res = res * x return res if area(apt_a) < area(apt_b): print("Apartment B") else: print("Apartment A")
2 Answers
+ 1
Inputs are separated by camma. So you need to split with camma( , ).
And also, since input is in string form, you need to convert it into integer values. Otherwise it leads to wrong result.
+ 1
Thanks for the tips. I edited my code as such and it worked.
a = input().split(",")
b = input().split(",")
apt_a = list(map(int, a))
apt_b = list(map(int, b))
def area(dim):
res = 1
for x in dim:
res = res * x
return res
if area(apt_a) < area(apt_b):
print("Apartment B")
else:
print("Apartment A")