Whatā€™s wrong with my code?!?!? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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