Python Forum
If 2nd input in the game is correct, replace with 1st input and loop the game - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: If 2nd input in the game is correct, replace with 1st input and loop the game (/thread-37730.html)

Pages: 1 2


RE: If 2nd input in the game is correct, replace with 1st input and loop the game - BashBedlam - Jul-16-2022

Always happy to help Smile


RE: If 2nd input in the game is correct, replace with 1st input and loop the game - deanhystad - Jul-17-2022

I would keep the word chain to report at the end of the game, or to compute a score.
words = [input('enter a country name: ')]
while True:
    word = input('enter a country name starts with the last letter of previous country name: ')
    if word and word[0].lower() == words[-1][-1].lower():
        words.append(word)
    else:
        break
print(f"So sorry, The first letter of {word} does not match the last letter of {words[-1]}.")
print(f"Your word chain {words}")