Below is the question and my attempted answer

5.4 Use the list of module titles from the previous exercise to create a for loop. It should ask the user for every title whether they would like to keep the title or delete it. Delete the titles which the user no longer wants.


# creating and modifying a list

module_list = ["Natural Language Processing", "Wireless Communication Systems", "Final Year Project", "Research Studies", "Internet Technologies", "Applied Mobile Technologies"]

nLoops = 6

for i in range(nLoops):

module_title = input(" Please enter a module title :  ")

new_item = input("Which item would you like to delete?\
Please input the name of the item: ")
if new_item in shopping_list:
      print (new_item, "has been deleted")
      print (new_item, "cannot be deleted because it is not in the module list")
print ("The module list has the following",\ len(module_list), "items:", module_list)

I keep getting an error expected an indented block.

Please help me fix this error and let me know if my code answers the 5.4 question



Recommended Answers

All 3 Replies

for at line 10 has no statements in it.

erm! your solution does not really suit your task, try this one instead.

moduleList = ["software engineering", "applied mobile technologies", "research studies", "concurrent programming", "natural language processing", "final year project"]

for i in moduleList:
print (i)
yesNo = input("delete this module? Y/N: ")

if yesNo == "y" or yesNo == "Y":
  print ("the module has been deleted\n")

    print ("no action taken\n")

print ("The module list now contains", len(moduleList), "modules:", moduleList)

p.s I got your own code running, you must indent as showen in the above solution.

p.p.s If this task is for Yuhua Li's class, then change it about to avoid plagiarism as I'm also in that class! Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.