<div><div>Hello!&nbsp; I'm also new, to both Python and this list, but I think I know this one, so it's a good chance for me to post.<br><br>The second block of code doesn't work either--it always sets stock = 2.&nbsp; I believe that the problem is that the code you've really written is:
<br><br>if (texture == &quot;flaky&quot;) or &quot;caked&quot;:<br>...<br><br>If either expression evaluates to True, the first block will be called.&nbsp; Problem is, bool(&quot;caked&quot;) evaluates to True, as bool(s) is False if s == &quot;&quot; and True otherwise, when s is a string.&nbsp; The reason for this is it allows for really brief code like, I dunno:
<br><br>a = &quot;Hello.&quot;<br>while a:<br>&nbsp;&nbsp;&nbsp; a = a[:-1]<br><br>This removes a character from the end of a until a is empty.<br><br>This code would work:<br><br>if texture == &quot;flaky&quot; or texture == &quot;caked&quot;:
<br>&nbsp;&nbsp;&nbsp; stock = 1<br>else:<br>&nbsp;&nbsp;&nbsp; stock = 2<br> <br><br>The problem with learning Python from a Pascal book is that you're going to miss all of the syntactical shortcuts that makes Python powerful.&nbsp; For instance, you could use the line 'if texture in [&quot;flaky&quot;,&quot;caked&quot;]'.&nbsp; There's definitely a good one-liner for this, (the veterans should chime in here) but the best I could come up with was this one: (it's a hack)
<br><br>stock = 2 - (texture in [&quot;flaky&quot;,&quot;caked&quot;])<br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>
<font face="Arial" size="2"><font color="#ff0000" face="Arial" size="2">if texture == 
&quot;flaky&quot; or &quot;caked&quot;:<br>&nbsp;&nbsp;&nbsp; stock = 1</font></font></div>
<div>
<div><font color="#ff0000"><font face="Arial" size="2">else:<br>&nbsp;&nbsp;&nbsp; 
stock =&nbsp;2</font>&nbsp;&nbsp;</font></div>
<div>&nbsp;</div>
<div>This never worked.&nbsp; Cigars with &quot;varied, fluffy, granular, &quot; textures 
always ended up as stock 1.&nbsp; So did the &quot;flaky and caked&quot;.&nbsp; </div>
<div>-----------------------------------------------------------------------------</div></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font face="Arial" size="2">When I changed the line to:</font></div>
<div><font face="Arial" size="2"></font>&nbsp;</div>
<div><font color="#ff0000" face="Arial" size="2">if texture != &quot;flaky&quot; or 
&quot;caked&quot;:<br>&nbsp;&nbsp;&nbsp; stock = 2<br>else:<br>&nbsp;&nbsp;&nbsp; stock = 
1</font></div>
<div><font face="Arial" size="2">the program works great.</font>&nbsp;<font face="Arial" size="2">&nbsp; I have no idea why.&nbsp; Can anyone help 
me.</font></div>
<div>&nbsp;</div></blockquote></div>