Python Editor

Python | Lesson2 | Nested For Loop


#Iterate through each loop and print

countries = ["USA", "UK", "Brazil"]
teams = ["Team1", "Team2", "Team3"]

for country in countries:
  for team in teams:
    print(country, team)


2 comments:

  1. I got syntax error SyntaxError: bad input on line 5 in main.py

    countries = ["USA", "UK", "Brazil"]
    teams = ["Team1", "Team2", "Team3"]

    for country in countries:
    for team in teams
    print(country, team)

    ReplyDelete
    Replies
    1. Semi colon is missing in second for loop. Add the semi colon and try

      Delete