# Why is my While Loop not looping?

here's my code:

x = int(input("How many rows to you want to print? "))

i = 0

print("Example: 3 -")
print("Output: ---")

while i < x:
inp = input()
result = ""
final = inp.split(" ")

for i in range(1, ((int(final[0]) - 1) + 2)):
result = result + (final[len(final) - 1])

print(result)

i += 1

...

Why is my while loop not working?

I'm trying to finish my homework, that is coding

question Problem J2 in this PDF

https://www.cemc.uwaterloo.ca/contests/computing/past_ccc_contests/2019/stage%201/juniorEF.pdf

Thankyou!!

answered Mar 3 by (69,270 points)

First of all, the inputs do not come separated by spaces, but in new lines. So inp.split(" ") will not separate the 3/2/1 scores into final.

Your

```    for i in range(1, ((int(final[0]) - 1) + 2)):
result = result + (final[len(final) - 1])```

is weird as well.

Here's what you should do:

• Read 3 lines. The first will contain the 3, the second the 2, and the third the 1-point shot counts.
• Then you calculate the total score by multiplying the counts (read from the three lines) with the score values (3/2/1).
• You do it for both teams (A and B) and print A or B depending on who has the higher score. Or T if it's a tie.
• When done, test it with the inputs provided in the PDF (example section). Then test it for more inputs on your own. Test for corner cases. Test if you determine the win of A, B, or even the tie.
commented Mar 3 by (150 points)
Thank you so much! It works now!
commented Mar 4 by (69,270 points)