Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:54:42+00:00 2026-06-13T03:54:42+00:00

#!/usr/bin/env python import easygui as eg start = eg.msgbox(‘In your head, pick a number

  • 0
#!/usr/bin/env python
import easygui as eg


start = eg.msgbox('In your head, pick a number between 1 and 100. No matter what, I will guess it in no more than 7 tries. When you think of a number, press OK to start the program.')

maximum = 100
minimum = 0
middle = (maximum-minimum)/2
attempt= 1
while True:
    if attempt > 7:
        eg.msgbox('You cheated. Terminating...')
        break
    else:   
        yon = eg.boolbox("Is your number: " + str(middle) + '?', 'Guess Result',('Yes','No'))
        if yon == 1:
            eg.msgbox("Found in " + str(attempt) + " try!")
            break
        if yon == 0:
            choice = eg.boolbox("Was my guess..." , 'High or Low?' , ('High' , 'Low')
        if choice == 0:
            minimum = middle
            middle = int(round(float(maximum+minimum)/2))
        elif choice == 1:
            maximum = middle
            middle = int(round(float(maximum+minimum)/2))
        else:
            eg.msgbox"Enter valid input!";"Lets start again from the last step"
            continue
        attempt+= 1

Okay, I keep getting an indent error on Line 20. I can’t figure it out. My syntax appears fine. I went back and deleted all the indents and re-indented them(to make sure there were no spaces in the mix). Why is it giving me this? How can I fix it?

What really confuses me the most is I have the same code written out, but without the EasyGUI module imported and without the EasyGUI modifications, but it’s the same code other than that. The if/elif/else’s are in the same spot, and everything is the same except the ‘print’ commands have been omitted for ‘eg.msgbox’ and the raw_input’s have been replaced with a ‘boolbox’.

EDIT – Line 20 is the:

 if yon == 0:

line

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:54:43+00:00Added an answer on June 13, 2026 at 3:54 am
    if yon == 0:
        choice = eg.boolbox("Was my guess..." , 'High or Low?' , ('High' , 'Low')
    

    You have missed one closing bracket.

    choice = eg.boolbox("Was my guess..." , 'High or Low?' , ('High' , 'Low'))
    

    Also, check your last else:. It should be: –

    else:
        eg.msgbox("Enter valid input!","Lets start again from the last step")
        continue
    

    You have not indented your last if properly:-

        if yon == 0:
            choice = eg.boolbox("Was my guess..." , 'High or Low?' , ('High' , 'Low')
        if choice == 0:
            minimum = middle
            middle = int(round(float(maximum+minimum)/2))
        elif choice == 1:
            maximum = middle
            middle = int(round(float(maximum+minimum)/2))
        else:
            eg.msgbox"Enter valid input!";"Lets start again from the last step"
            continue
    

    All your if-elif-else should be inside your outer if. You are checking condition on variable defined inside that.. So re-indent your structure to: –

    if yon == 0:
        choice = eg.boolbox("Was my guess..." , 'High or Low?' , ('High' , 'Low')
        if choice == 0:
            minimum = middle
            middle = int(round(float(maximum+minimum)/2))
        elif choice == 1:
            maximum = middle
            middle = int(round(float(maximum+minimum)/2))
        else:
            eg.msgbox"Enter valid input!";"Lets start again from the last step"
            continue
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
#! /usr/bin/env python import os import stat import sys class chkup: def set(file): filepermission
#!/usr/bin/env python import os, sys, subprocess, time while True: print subprocess.call(xsel, shell=True); time.sleep(1); Takes
the code here below: #!/usr/bin/env python import wx class MyForm(wx.Frame): def __init__(self): wx.Frame.__init__(self, None,
I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore
I'm running a simple python script sending data to a mongodb #!/usr/bin/env python import
The Problem This code #!/usr/bin/env python import pynotify import time import datetime c='5/1/12 1:15
The following code: #!/usr/bin/env python import mechanize class MechanizeSubclass(mechanize.Browser): def __init__(self, factory=None, history=None, request_class=None,
The following python script works fine: #!/usr/bin/env python import httplib, urllib params = urllib.urlencode({'url':'xxx/xxx/0AAAUw7n6qPQ922.jpg',
Simple code demonstrating the problem: #!/usr/bin/env python import sys from PyQt4.QtCore import QObject, SIGNAL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.