What’s wrong with my code?!?!? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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")

27th Sep 2023, 2:19 AM
Josh
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.
27th Sep 2023, 3:37 AM
Jayakrishna 🇮🇳
+ 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")
27th Sep 2023, 5:47 PM
Josh