<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">elif is what you want to use. Here try this. :)<div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">elif = else if</div><div class=""><br class=""></div><div class="">I added the g=0 because the variable needed to be defined.</div><div class="">Same with guess.</div><div class=""><br class=""></div><span class=""><br class=""></span><span class="">#!/usr/bin/env python<br class="">print("Welcome.")<br class="">g=0<br class="">guess = int(g)<br class="">while guess != 5:<br class="">    g = input("Guess the number: ")<br class="">    guess = int(g)<br class="">    if guess < 5:<br class="">        print("Guess higher.")<br class="">    elif guess > 5:<br class="">        print("Guess lower.")<br class="">    else:<br class="">        print("Correct.”)</span><div class=""><span class=""><br class=""></span></div><div class=""><span class="">jason<br class=""></span><span class=""><br class=""></span><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 13, 2015, at 1:34 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" class="">bmike1@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Okay Jason, I did it your way. The resulting code being 2 lines shorter. Unfortunately I still have the same problem as before (that being if the guess is wrong it gives no suggestion as to higher/lower but rather just asks you to guess again):<div class=""><br class=""></div><div class=""><div class="">python 1-30guess.py </div><div class="">Welcome.</div><div class="">Guess the number: 0</div><div class="">Guess the number: 0</div><div class="">Guess higher.</div><div class="">Guess the number: 9</div><div class="">Guess lower.</div><div class="">Guess the number: 8</div><div class="">Guess lower.</div><div class="">Guess the number: 7</div><div class="">Guess lower.</div><div class="">Guess the number: 6</div><div class="">Guess lower.</div><div class="">Guess the number: 5</div><div class="">Guess lower.</div><div class="">Correct.</div></div><div class=""><br class=""></div><div class=""> here is the code:</div><div class=""><div class=""><br class=""></div><div class="">#!/usr/bin/env python</div><div class="">print("Welcome.")</div><div class="">g = input("Guess the number: ")</div><div class="">guess = int(g)</div><div class="">while guess != 5:</div><div class="">    g = input("Guess the number: ")</div><div class="">    guess = int(g)</div><div class="">    if guess < 5:</div><div class="">        print("Guess higher.")</div><div class="">    else:</div><div class="">        print("Guess lower.")</div><div class="">print("Correct.")      </div></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature">:-)~MIKE~(-:</div></div>
<br class=""><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:48 PM, Sesso <span dir="ltr" class=""><<a href="mailto:sesso@djsesso.com" target="_blank" class="">sesso@djsesso.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">You may be better off using if statements.<div class=""><br class=""></div><div class=""><br class=""></div><div class="">If number is less than 5</div><div class=""><br class=""></div><div class="">print guess higher</div><div class=""><br class=""></div><div class="">else </div><div class=""><br class=""></div><div class="">print guess lower</div><div class=""><br class=""></div><div class="">Then wrap all of that in a while loop with a condition of while less than 5.</div><div class=""><br class=""></div><div class="">Jason</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2015, at 12:44 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank" class="">bmike1@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">however it does give suggestions on subsequent guesses....</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="">:-)~MIKE~(-:</div></div>
<br class=""><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:42 PM, Michael Havens <span dir="ltr" class=""><<a href="mailto:bmike1@gmail.com" target="_blank" class="">bmike1@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">here is what I have (that sorta works):<div class=""><br class=""></div><div class=""><span class=""><div class="">print("Welcome.")</div><div class="">g = input("Guess the number: ")</div><div class="">guess = int(g)</div></span><div class="">while guess < 5:</div><span class=""><div class="">    g = input("Guess the number: ")</div><div class="">    guess = int(g)</div></span><div class="">    print("Guess higher.")</div><div class="">while guess > 5:</div><span class=""><div class="">    g = input("Guess the number: ")</div><div class="">    guess = int(g)</div></span><div class="">    print ("Guess lower.")</div><div class="">print("Correct")</div></div><div class=""><br class=""></div><div class=""> What I mean by 'sorta' is if the first guess is not correct  it does not give a suggestion to guess lower or higher. Why is this?</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="">:-)~MIKE~(-:</div></div><div class=""><div class="">
<br class=""><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:32 PM, Michael Havens <span dir="ltr" class=""><<a href="mailto:bmike1@gmail.com" target="_blank" class="">bmike1@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">that makes sense... thanks!</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="">:-)~MIKE~(-:</div></div><div class=""><div class="">
<br class=""><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:31 PM, Sesso <span dir="ltr" class=""><<a href="mailto:sesso@djsesso.com" target="_blank" class="">sesso@djsesso.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">The while needs to before input so that it will wait for input if the variable is not equal to 5.</div><div class=""><br class=""></div><div class="">Jason</div><div class=""><div class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Apr 13, 2015, at 12:21 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank" class="">bmike1@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">nope. that didn't fix it.<br class=""><br class=""></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="">:-)~MIKE~(-:</div></div>
<br class=""><div class="gmail_quote">On Mon, Apr 13, 2015 at 11:46 AM, Amit Nepal <span dir="ltr" class=""><<a href="mailto:amit@amitnepal.com" target="_blank" class="">amit@amitnepal.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You would probably want to wait and ask for the input inside the loop as well. What you seem to be doing is you ask for input and then you execute the loop not letting the user input the new number and thus running into an infinite loop.<br class="">
<br class="">
This might fix it, not tested though :)<span class=""><br class="">
<br class="">
print("Welcome.")<br class="">
g = input("Guess the number: ")<br class="">
guess = int(g)<br class="">
<br class="">
while guess != 5<br class="">
    print("Guess again.")<br class=""></span>
    guess = int(g)<br class="">
    print("Correct")<br class="">
<br class="">
<br class="">
Thanks<span class=""><font color="#888888" class=""><br class="">
Amit</font></span><span class=""><br class="">
On 4/13/2015 11:01 AM, Michael Havens wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
print("Welcome.")<br class="">
g = input("Guess the number: ")<br class="">
guess = int(g)<br class="">
while guess != 5:<br class="">
    print("Guess again.")<br class="">
print("Correct")<br class="">
</blockquote>
<br class=""></span><div class=""><div class="">
------------------------------<u class=""></u>---------------------<br class="">
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" class="">PLUG-discuss@lists.phxlinux.<u class=""></u>org</a><br class="">
To subscribe, unsubscribe, or to change your mail settings:<br class="">
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank" class="">http://lists.phxlinux.org/<u class=""></u>mailman/listinfo/plug-discuss</a><br class="">
</div></div></blockquote></div><br class=""></div>
---------------------------------------------------<br class="">PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" class="">PLUG-discuss@lists.phxlinux.org</a><br class="">To subscribe, unsubscribe, or to change your mail settings:<br class=""><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank" class="">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br class=""></div></div></div><br class="">---------------------------------------------------<br class="">
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" class="">PLUG-discuss@lists.phxlinux.org</a><br class="">
To subscribe, unsubscribe, or to change your mail settings:<br class="">
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank" class="">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br class=""></blockquote></div><br class=""></div></div></div>
</blockquote></div><br class=""></div></div></div></div>
</blockquote></div><br class=""></div>
---------------------------------------------------<br class="">PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank" class="">PLUG-discuss@lists.phxlinux.org</a><br class="">To subscribe, unsubscribe, or to change your mail settings:<br class=""><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank" class="">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br class=""></div></div></div></div><br class="">---------------------------------------------------<br class="">
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" class="">PLUG-discuss@lists.phxlinux.org</a><br class="">
To subscribe, unsubscribe, or to change your mail settings:<br class="">
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank" class="">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br class=""></blockquote></div><br class=""></div>
---------------------------------------------------<br class="">PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" class="">PLUG-discuss@lists.phxlinux.org</a><br class="">To subscribe, unsubscribe, or to change your mail settings:<br class=""><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" class="">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br class=""></div></div></body></html>