Why does the loop start after I enter the first value for team A even though it's less than 15?

Question:

Why does the loop start after I enter the first value for team A even though it’s less than 15?
After I enter the first value it doesn’t go to the next loop where I am supposed to enter the value again until it reaches 15.

team_a = int(input("Please enter the score for team A: ")) 
team_b = int(input("Please enter the score for team B: "))  
team_a_score = 0 
team_b_score = 0 
Round = 0  
total_score = 15  

while total_score>team_a_score:

  team_a_score+=team_a 

  if total_score<team_a_score: 
  break 
print("the game is over")
Asked By: alex

||

Answers:

there should be a space before break, your intention was wrong! Corrected it

team_a = int(input("Please enter the score for team A: ")) 
team_b = int(input("Please enter the score for team B: "))  
team_a_score = 0 
team_b_score = 0 
Round = 0  
total_score = 15  

while total_score>team_a_score:

  team_a_score+=team_a 

  if total_score<team_a_score: 
   break 
print("the game is over")
Answered By: SmartestVEGA

Now you enter values only one time.
If you want to enter values in loop it should look like this:

team_a_score = 0 
team_b_score = 0 
Round = 0  
total_score = 15  

while total_score>team_a_score:
    team_a = int(input("Please enter the score for team A: ")) 
    team_b = int(input("Please enter the score for team B: "))  
    team_a_score+=team_a 

    if total_score<team_a_score: 
        break 
print("the game is over")
Answered By: Isem

Why don’t you ask the input inside your loop ?

team_a_score = 0
total_score = 15  

while total_score > team_a_score:

  team_a = int(input("Please enter the score for team A: ")) 

  team_a_score += team_a 

print("the game is over")
Answered By: Marco Bresson
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.