Exercism Python Bob
<p>I'm learning Python through Exercism.IO, I'm currently on the <code>Bob</code> problem where the object of the problem is as follows:</p>

<blockquote>
  <p>Bob is a lackadaisical teenager. In conversation, his responses are very limited.
  Bob answers 'Sure.' if you ask him a question.
  He answers 'Whoa, chill out!' if you yell at him.
  He says 'Fine. Be that way!' if you address him without actually saying
  anything.
  He answers 'Whatever.' to anything else.</p>
</blockquote>

<p>So far I've passed a few tests and I'm stuck at a point where it's suppose to return <code>whatever</code> but all the characters are integers, so of course it's not working.</p>

<p>Here's where I'm failing:</p>

<pre><code>def test_only_numbers(self):
    self.assertEqual(
        'Whatever.', bob.hey('1, 2, 3')
    )
</code></pre>

<p>All the characters are integers and my test to see if they're yelling looks like this:</p>

<pre><code>def is_yelling(self):
    return self.sentence == self.sentence.upper()
</code></pre>

<p>Obviously the characters are the same when upper or lower case because they're numbers so the program thinks they're yelling. My question is how can I refactor this program to make it so that when the assertion is all numbers, it won't count it as yelling?</p>

<pre><code>def hey(what):
    sentence = SentenceThinker(what)
    if sentence.is_silence():
        return "Fine. Be that way!"
    elif sentence.is_yelling():
        return "Whoa, chill out!"
    elif sentence.is_question():
        return "Sure."
    else:
        return "Whatever."


class SentenceThinker(object):

    def __init__(self, sentence):
        self.sentence = sentence

    def is_yelling(self):
        return self.sentence == self.sentence.upper()

    def is_question(self):
        return self.sentence.endswith("?")

    def is_silence(self):
        return not self.sentence
</code></pre>

<p>consider using the built-in String method <a href="https://docs.python.org/3/library/stdtypes.html#str.isupper" rel="nofollow"><code>str.isupper()</code></a></p>

python