Python Case Matching Input and Output
<p>I'm doing the pig latin question that I'm sure everyone here is familiar with it. The only thing I can't seem to get is matching the case of the input and output. For example, when the user enters Latin, my code produces <code>atinLay</code>. I want it to produce <code>Atinlay</code>.</p>

<pre><code>import string

punct = string.punctuation
punct += ' '
vowel = 'aeiouyAEIOUY'
consonant = 'bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ'

final_word = input("Please enter a single word. ")
first_letter = final_word[:1]

index = 0

if any((p in punct) for p in final_word):
    print("You did not enter a single word!")
else:
    while index &lt; len(final_word) and (not final_word[index] in vowel):
        index = index+1
    if any((f in vowel) for f in first_letter):
        print(final_word + 'yay')
    elif index &lt; len(final_word):
        print(final_word[index:]+final_word[:index]+'ay')
</code></pre>

<p>What you need is <a href="http://docs.python/3/library/stdtypes.html#str.title" rel="nofollow"><code>str.title()</code></a>. Once you have done your piglatin conversion, you can use <code>title()</code> built-in function to produce the desired output, like so:</p>

<pre><code>&gt;&gt;&gt; "atinLay".title()
'Atinlay'
</code></pre>

<p>To check if a string is lower case, you can use <a href="http://docs.python/3/library/library/stdtypes.html#str.islower" rel="nofollow"><code>str.islower()</code></a>. Take a peek at the docs.</p>

python string