fb pixel

Introduction to Python

  • Profound Academy

    • Status
      • 1
        Input and Output
      • 2
        Variables and Integer Arithmetic
      • 3
        Conditional Operators
      • 4
        Advanced Conditions - Nesting
      • 5
        Types and Variables
      • 6
      • 7
      • 8
        For Loops
      • 9
        While Loops
      • 10
        continue, break, while...else
      • 11
        String and List methods
      • 12
        Nested Loops
      • 13
        List Comprehension
      • 14
        Tuples and Sets
      • 15
      • 16
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19

  • Cities

    When playing the cities game each player has to name a city, and the next player has to name a city that starts with the last letter of the city that was just named. So, if someone said Moscow, the next player can say Warsaw as Moscow ends with w.
    Given a game where each new city is separated from the previous one with a comma and a space, your task is to find out if it’s a valid game. Otherwise, you should tell that someone has already lost.
    The input contains a single line where each named city is separated by a ', ' from the previous one.
    The program should output Go on if the game is valid so far, and Stop! if someone messed up in the chain of cities.
    Moscow, Warsaw, West Jordan, Nashville
    Go on
    Warsaw, Moscow
    Moscow, Amsterdam
    To check your solution you need to sign in
    Sign in to continue