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 670453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:15:51+00:00 2026-05-14T00:15:51+00:00

I have two begininer programs, both using the ‘while’ function, one works correctly, and

  • 0

I have two begininer programs, both using the ‘while’ function, one works correctly, and the other gets me stuck in a loop. The first program is this;

num=54
bob = True
print('The guess a number Game!')


while bob == True:
    guess = int(input('What is your guess?  '))

    if guess==num:
        print('wow! You\'re awesome!')
        print('but don\'t worry, you still suck')
        bob = False
    elif guess>num:
        print('try a lower number')
    else:
        print('close, but too low')

print('game over')``

and it gives the predictable output of;

The guess a number Game!
What is your guess?  12
close, but too low
What is your guess?  56
try a lower number
What is your guess?  54
wow! You're awesome!
but don't worry, you still suck
game over

However, I also have this program, which doesn’t work;

#define vars
a = int(input('Please insert a number: '))
b = int(input('Please insert a second number: '))

#try a function
def func_tim(a,b):
    bob = True
    while bob == True:
        if a == b:
            print('nice and equal')
            bob = False
        elif b > a:
             print('b is picking on a!')
        else:
            print('a is picking on b!')
#call a function
func_tim(a,b)

Which outputs;

Please insert a number: 12
Please insert a second number: 14
b is picking on a!
b is picking on a!
b is picking on a!
...(repeat in a loop)....

Can someone please let me know why these programs are different? Thank you!

  • 1 1 Answer
  • 4 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-05-14T00:15:51+00:00Added an answer on May 14, 2026 at 12:15 am

    In the second program you never give the user a chance to pick two new numbers if they’re not equal. Put the lines where you get input from the user inside the loop, like this:

    #try a function
    def func_tim():
        bob = True
        while bob == True:
            #define vars
            a = int(input('Please insert a number: '))
            b = int(input('Please insert a second number: '))
    
            if a == b:
                print('nice and equal')
                bob = False
            elif b > a:
                 print('b is picking on a!')
            else:
                print('a is picking on b!')
    #call a function
    func_tim()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As long as all the arrays are the same length,… May 14, 2026 at 8:27 pm
  • Editorial Team
    Editorial Team added an answer You can't. This would be a security hole. Now that… May 14, 2026 at 8:27 pm
  • Editorial Team
    Editorial Team added an answer When a partial submit is executed, the full JSF lifecycle… May 14, 2026 at 8:27 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.