Note that there are some explanatory texts on larger screens.

plurals
  1. POBasic Python Question on String operations: example: string.lowercase
    text
    copied!<p>So I'm trying to run this, but it errors out and I need help understanding what's wrong. I really appreciate any help, I'm taking the MIT opencourseware intro to programming:</p> <pre><code>words="GreatTimes" words.lowercase </code></pre> <p>And I get this error:</p> <pre><code>AttributeError: 'str' object has no attribute 'lowercase' </code></pre> <p>The issue is that I'm trying to run example code from "How to think like a computer scientist" and it still gives me the error.</p> <pre><code>def isLower(ch): return string.find(string.lowercase, ch) != -1 </code></pre> <p>So I can't figure out what the syntax error is. Looking at the <a href="http://docs.python.org/library/string.html" rel="nofollow">Python doc page</a> it says this:</p> <blockquote> <p>string.lowercase A string containing all the characters that are considered lowercase letters. On most systems this is the string 'abcdefghijklmnopqrstuvwxyz'. The specific value is locale-dependent, and will be updated when locale.setlocale() is called.</p> </blockquote> <p>Thoughts?</p> <p>Edit: Ah, sorry I should be more clear. So I'm trying to write a piece of code that will tell me whether or not a character in a string is lowercase or not. my code is my implementation of it. while the example code is something i'm using to try to check to see if my syntax is wrong and that is the source of the problem. However, the example code also generates an error. In a nutshell, why doesn't this code work? It seems like it Should spit out a string of all the lowercase letters like "reatimes" from "GreatTimes" And/or how would you use string.lowercase to make this program?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload