Question: I'm new to python and I'm stuck on this particular exercise.
I'm trying to make a program to take an input from the user (a string) and switch all the vowels to lowercase and consonants to uppercase.

Example input: `"Learning python is fun."`  

Expected output: `"LeaRNiNG PYTHoN iS FuN."`

This is what I've tried:

```
def toggle(phrase):
    for letter in phrase:
        if letter not in "aeiou":
            letter = letter.upper()
        elif letter in "AEIOU":
            letter = letter.lower()
        else:
            letter = letter.upper()
    return phrase

print(toggle(input("Enter a phrase: ")))

```

However, the output is not toggling anything. What am I missing?

Answer: 
The issue is you're looping over an iterable of the phrase and by assigning letter you aren't actually changing the letters in phrase.

You could turn the whole string to upper then use `str.translate`

```
vowel_trans = str.maketrans('AEIOU', 'aeiou')
def toggle(phrase):
    return phrase.upper().translate(vowel_trans)

```

In the case this will not suffice you can generate a string while looping using the same logic and return that string.

```
def toggle(phrase):
    new_phrase = ''
    for letter in phrase.upper():
        if letter in 'AEIOU':
            new_phrase += letter.lower()
        else:
            new_phrase += letter

```

**EDIT**

This can be shortened to a comprehension as well:

```
def toggle(phrase):
    return ''.join(l.lower() if l in 'AEIOU' else l for letter in phrase)

```

Or even done using `re`:

```
import re

def toggle(phrase):
    return re.sub('AEIOU', 'aeiou', phrase.upper())

```
I assume you meant to say "All the vowels are lowercase and all the consonants are uppercase"

```
def toggle(phrase):
    new_phrase = ""
    for letter in phrase:
        if letter in ['a', 'e', 'i', 'o', 'u'] or letter in ['A', 'E', 'I', 'O', 'U']:
            new_phrase += letter.lower()
        else:
            new_phrase += letter.upper()
    return new_phrase

print(toggle(input("Enter a phrase: ")))

```