Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Lists Redux Removing Items From A List

Brent Liang
PLUS
Brent Liang
Courses Plus Student 2,944 Points

Unexpected indent/EOF when parsing?

list_of_word = []
x = 0
y = 0
z = 0
vowels = [a,e,i,o,u]
control = input("This is an interesting game. Press anything to begin. Press q to quit at all times!")
if control == "q":
  quit()
else:
  while True:
    added = [input.lower("Type DONE to complete, otherwise, give me the {} word!".format(x))] 
    x += 1
    list_of_word.append(added)
    print("Okay, let's move on!")
    if added == "DONE":
      def un_vowelled (list_of_word):
        try:
          for item in list_of_word:
            if item.index[y] == item in vowels:
              del item [y]
              y += 1
              if y == len(item):
                y = 0
                z += 1 
                if z == len(list_of_word):
                  print("Here's your new list:")
                  print(list_of_word)
                  break 
                else:
                  continue
              else:
                continue
            else:
              y += 1
              if y == len(item):
                y = 0
                z += 1
                if z == len(list_of_word):
                  print("Here's your new list:")
                  print(list_of_word)
                  break
                else:
                  continue
              else:
                continue
    else:
      continue

What's wrong with this code?

Your code is very confusing, you have way too much going on.

Are you trying to achieve the following?

- User inputs different words one at a time which gets
appended to an empty list variable

- When user submits 'DONE' as a word item, a function is triggered

- The function strips all the vowels out of each word the user input

- function prints out a list of words without their vowels.

- script quits python shell after print

If this isn't what you're trying to achieve, please provide a breakdown of what you're trying to achieve.

Name:GoogleSearch orJonathan Sum
Name:GoogleSearch orJonathan Sum
5,039 Points

I am a noob. From what i have seen that "Unexpected indent/EOF when parsing" means missing "()" sign or indent error

Every time you create a block u need to indent 4 spaces infront of the first line of the block.

Here is a example. Moreover, i see your coding having more python syntax error

def functionA (a1,a2):
    return (a1, a2)   
# After another new line after the function ,which is "def functionA (a1,a2)" ,there is 4 spaces infront of the word"return". It #is not just function. if you want to use if or else statment ,you also need to do this.


#.lower() is a function ,but it doesn't mean u need to put whatever you want to convert to lower case in to the "()" sign.
#You need to put whatever you want to convert to lowercase infront of the ".lower()".

#Therefore,it should be this.
added = [input("Type DONE to complete, otherwise, give me the {} word!".format(x)).lower()]

#i haven't gone over more. If there is no1 doing this, i will do this later.

2 Answers

Zach Hudson
Zach Hudson
7,702 Points

Try looking at this:

while True:
    added = input("Type DONE to complete, otherwise, give me the {} word!".format(x)).lower()

I changed the above line to have the .lower() after the input expression.

It looks like you have a indentation issue with the last else/continue. I put it into Pycharm and get an indentation error for that line.

Brent Liang
PLUS
Brent Liang
Courses Plus Student 2,944 Points

Yeah thanks all, not entirely sure what's wrong with the indentation but I've tried achieving the same objective using a more succinct body of code and it worked.

Thank you all for the answers! I am choosing Zach's as the best answer. I really appreciate the comments Michael and Jonathan!