<div dir="ltr">It's a bad variable name is all. It could be supercalifragilisticexpialidocious = input<br>But, it's not really descriptive. A better name would probably be raw_user_guess = input</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 13, 2015 at 7:30 PM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Cool, that is sorta how I wrote it before though they haven't gone over elif yet. As a result of that<i> </i>I deleted '<span style="color:rgb(80,0,80);font-size:12.8000001907349px">g = input("Guess the number: ")' and it kept complaining about the variable not being defined. </span>Question though:<div>could we change the 'g' to some other letter...... never mind! I just tried it with 'w' and it works. What does that digit represent?</div></div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div><div><div class="h5">
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 3:04 PM, Sesso <span dir="ltr"><<a href="mailto:sesso@djsesso.com" target="_blank">sesso@djsesso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">elif is what you want to use. Here try this. :)<div><br></div><div><br></div><div><br></div><div>elif = else if</div><div><br></div><div>I added the g=0 because the variable needed to be defined.</div><div>Same with guess.</div><div><br></div><span><br></span><span><span>#!/usr/bin/env python<br>print("Welcome.")<br></span>g=0<span><br>guess = int(g)<br>while guess != 5:<br> g = input("Guess the number: ")<br> guess = int(g)<br> if guess < 5:<br> print("Guess higher.")<br></span> elif guess > 5:<br> print("Guess lower.")<br> else:<br> print("Correct.”)</span><div><span><br></span></div><div><span>jason<br></span><div><div><span><br></span><div><br></div><div><br><div><blockquote type="cite"><div>On Apr 13, 2015, at 1:34 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:</div><br><div><div dir="ltr">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><br></div><div><div>python 1-30guess.py </div><div>Welcome.</div><div>Guess the number: 0</div><div>Guess the number: 0</div><div>Guess higher.</div><div>Guess the number: 9</div><div>Guess lower.</div><div>Guess the number: 8</div><div>Guess lower.</div><div>Guess the number: 7</div><div>Guess lower.</div><div>Guess the number: 6</div><div>Guess lower.</div><div>Guess the number: 5</div><div>Guess lower.</div><div>Correct.</div></div><div><br></div><div> here is the code:</div><div><div><br></div><div>#!/usr/bin/env python</div><div>print("Welcome.")</div><div>g = input("Guess the number: ")</div><div>guess = int(g)</div><div>while guess != 5:</div><div> g = input("Guess the number: ")</div><div> guess = int(g)</div><div> if guess < 5:</div><div> print("Guess higher.")</div><div> else:</div><div> print("Guess lower.")</div><div>print("Correct.") </div></div></div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:48 PM, Sesso <span dir="ltr"><<a href="mailto:sesso@djsesso.com" target="_blank">sesso@djsesso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">You may be better off using if statements.<div><br></div><div><br></div><div>If number is less than 5</div><div><br></div><div>print guess higher</div><div><br></div><div>else </div><div><br></div><div>print guess lower</div><div><br></div><div>Then wrap all of that in a while loop with a condition of while less than 5.</div><div><br></div><div>Jason</div><div><div><div><br></div><div><br></div><div><br><div><blockquote type="cite"><div>On Apr 13, 2015, at 12:44 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:</div><br><div><div dir="ltr">however it does give suggestions on subsequent guesses....</div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:42 PM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">here is what I have (that sorta works):<div><br></div><div><span><div>print("Welcome.")</div><div>g = input("Guess the number: ")</div><div>guess = int(g)</div></span><div>while guess < 5:</div><span><div> g = input("Guess the number: ")</div><div> guess = int(g)</div></span><div> print("Guess higher.")</div><div>while guess > 5:</div><span><div> g = input("Guess the number: ")</div><div> guess = int(g)</div></span><div> print ("Guess lower.")</div><div>print("Correct")</div></div><div><br></div><div> 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"><div><div>:-)~MIKE~(-:</div></div><div><div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:32 PM, Michael Havens <span dir="ltr"><<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">that makes sense... thanks!</div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div><div><div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 12:31 PM, Sesso <span dir="ltr"><<a href="mailto:sesso@djsesso.com" target="_blank">sesso@djsesso.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>The while needs to before input so that it will wait for input if the variable is not equal to 5.</div><div><br></div><div>Jason</div><div><div><div><br></div><div><br></div><div><blockquote type="cite"><div>On Apr 13, 2015, at 12:21 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:</div><br><div><div dir="ltr">nope. that didn't fix it.<br><br></div><div class="gmail_extra"><br clear="all"><div><div>:-)~MIKE~(-:</div></div>
<br><div class="gmail_quote">On Mon, Apr 13, 2015 at 11:46 AM, Amit Nepal <span dir="ltr"><<a href="mailto:amit@amitnepal.com" target="_blank">amit@amitnepal.com</a>></span> wrote:<br><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>
<br>
This might fix it, not tested though :)<span><br>
<br>
print("Welcome.")<br>
g = input("Guess the number: ")<br>
guess = int(g)<br>
<br>
while guess != 5<br>
print("Guess again.")<br></span>
guess = int(g)<br>
print("Correct")<br>
<br>
<br>
Thanks<span><font color="#888888"><br>
Amit</font></span><span><br>
On 4/13/2015 11:01 AM, Michael Havens wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
print("Welcome.")<br>
g = input("Guess the number: ")<br>
guess = int(g)<br>
while guess != 5:<br>
print("Guess again.")<br>
print("Correct")<br>
</blockquote>
<br></span><div><div>
------------------------------<u></u>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.<u></u>org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/<u></u>mailman/listinfo/plug-discuss</a><br>
</div></div></blockquote></div><br></div>
---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br></div></div></div><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br></div></div></div></div><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>
---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a></div></blockquote></div><br></div></div></div></div></div><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
<br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Todd Millecam</div>
</div>