title: Python project basing on picture to guess the answer for the flag name , I think that the while loop is the problem
body: <p>My code snippet:</p>
  <pre class="lang-py prettyprint-override"><code>import tkinter
  from tkinter import Label, Canvas, PhotoImage, Frame, Entry, Button
  
  # Create the function instruction.
  def instruction():
      tkinter.messagebox.showinfo('Welcome To the Flag Guessing Game',
                                  'You have 3 attempts to play this game '
                                  'There are 6 countries in this game '
                                  'you can answer AU for Australia,  JP for Japan , '
                                  'NO for Norway,'
                                  ' NRA for Nigeria, '
                                  'NL for Netherland, '
                                  'UK for United Kingdom')
  
  
  # Create the function for show the picture on frame.
  def image_start():
      first_image = Label(frame1, image=Image1)
      first_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  def image_two():
      second_image = Label(frame1, image=Image2)
      second_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  def image_three():
      second_image = Label(frame1, image=Image3)
      second_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  def image_forth():
      second_image = Label(frame1, image=Image4)
      second_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  def image_fifth():
      second_image = Label(frame1, image=Image5)
      second_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  def image_sixth():
      second_image = Label(frame1, image=Image6)
      second_image.place(relx=0.5, rely=0.15, relwidth=0.7, relheight=0.6, anchor='n')
  
  
  turns = 3
  # Create the function for button and check the entry,
  while turns &gt; 0:
      def flag_check(entry):
          # create the global variable turns
          global turns
          # if the answer is AU, it will be right and move to next image
          if entry == &quot;AU&quot;:
              tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
              image_two()
              if entry == &quot;JP&quot;:
                  tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
                  image_three()
              else:
                  tkinter.messagebox.showinfo('Answer', 'You are wrong')
                  turns -= 1
                  if entry == 'Netherlands' or entry == 'NL':
                      tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
                      image_forth()
                  else:
                      tkinter.messagebox.showinfo('Answer', 'You are wrong')
                      turns -= 1
                      if entry == 'Nigeria' or entry == 'NRA':
                          tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
                          image_fifth()
                      else:
                          tkinter.messagebox.showinfo('Answer', 'You are wrong')
                          turns -= 1
                          if entry == 'United Kingdom' or entry == 'UK':
                              tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
                              image_sixth()
                          else:
                              tkinter.messagebox.showinfo('Answer', 'You are wrong')
                              turns -= 1
                              if entry == 'Norway' or entry == 'NO':
                                  tkinter.messagebox.showinfo('Answer', 'Congratulation, you got it!')
                              else:
                                  tkinter.messagebox.showinfo('Answer', 'You are wrong')
                                  turns -= 1
          else:
              tkinter.messagebox.showinfo('Answer', 'You are wrong')
              turns -= 1
  else:
      tkinter.messagebox.showinfo('Answer', 'You are wrong 3 times, Sorry Game Over')
  # Create the root windows.
  root = tkinter.Tk()
  width = 1000
  height = 800
  Image1 = PhotoImage(file='Australia.png')
  Image2 = PhotoImage(file='Japan.png')
  Image3 = PhotoImage(file='Netherlands.png')
  Image4 = PhotoImage(file='Nigeria.png')
  Image5 = PhotoImage(file='UK.png')
  Image6 = PhotoImage(file='Norway.png')
  # Create the canvas with the height and width we want, here I use 1000 and 800 which stored in the variable above
  canvas = Canvas(root, height=height, width=width)
  canvas.pack()
  # Create the background of the game by using PhotoImage.
  background = PhotoImage(file='USA.png')
  label_background = Label(root, image=background)
  label_background.place(relwidth=1, relheight=1)
  # Create the frame on the top which content the question and instruction for game.
  frame1 = Frame(root, bg='#0a202b', bd=10)
  frame1.place(relx=0.5, rely=0.05, relwidth=0.85, relheight=0.7, anchor='n')
  label = Label(frame1)
  label.place(relwidth=1, relheight=1)
  # Create the button and entry in frame2 for user can submit the answer.
  frame2 = Frame(root, bg='#0a202b', bd=10)
  frame2.place(relx=0.5, rely=0.8, relwidth=0.85, relheight=0.15, anchor='n')
  entry = Entry(frame2, font=40)
  entry.place(relwidth=0.6, relheight=1)
  button = Button(frame2, text=&quot;Submit&quot;, font=12, bg='grey', command=lambda: flag_check(entry.get()))
  button.place(relx=0.65, relwidth=0.35, relheight=1)
  image_start()
  title = Label(root, text=&quot;Welcome To the Flag Guessing Game&quot;, font=120, bg='white')
  title.place(relx=0.5, rely=0.1, relwidth=0.6, relheight=0.05, anchor='n')
  # info = Button(root, text=&quot;Welcome To the Flag Guessing Game&quot;, font=100, command=instruction)
  info = Button(root, text=&quot;Click here for instruction&quot;, font=100, bg='grey', command=instruction)
  info.place(relx=0.5, rely=0.65, relwidth=0.2, relheight=0.05, anchor='n')
  textbox = Label(frame2, text=&quot;Your answer: &quot;, font=100, bg='white')
  textbox.place(relx=0.02, rely=0.03, relwidth=0.3, relheight=0.2)
  # Call the first image show on frame1.
  root.mainloop()
  </code></pre>
  <p>I want to program a guessing game basing on the image of the flags from different countries. There are 6 countries which I picked. The user will have maximum 3 turns, if they are wrong 3 times, the game will end. The user cannot move to the next image until they guess correctly the current image right. I think the problem is the loop.</p>