Question: Given a list of Star Wars characters, Make a second list that includes only the characters whose name is a single word. Print each value

Given a list of Star Wars characters, Make a second list that includes only the characters whose name is a single word. Print each value of the new list to the screen

.Instructions

  1. You have been provided with a collection of characters from Star Wars. Examine the provided information and structure it so that you can iterate through it.
  2. Make an empty Python list named single_word_names
  3. Using a loop, examine each character. If the character's name is a single word, append it to the list you make above. (Hyphenated names are considered to be single word names. For example, Ki-Adi-Mundi should be included in your single_word_names list.)
  4. Print the single_word_names list to the console

filter name:

def main():

  

names = 'Luke Skywalker, C-3PO, R2-D2, Darth Vader, Leia Organa, Owen Lars, Beru Whitesun lars, R5-D4, Biggs Darklighter, Obi-Wan Kenobi, Anakin Skywalker, Wilhuff Tarkin, Chewbacca, Han Solo, Greedo, Jabba Desilijic Tiure, Wedge Antilles, Jek Tono Porkins, Yoda, Palpatine, Boba Fett, IG-88, Bossk, Lando Calrissian, Lobot, Ackbar, Mon Mothma, Arvel Crynyd, Wicket Systri Warrick, Nien Nunb, Qui-Gon Jinn, Nute Gunray, Finis Valorum, Jar Jar Binks, Roos Tarpals, Rugor Nass, Ric Oliu, Watto, Sebulba, Quarsh Panaka, Shmi Skywalker, Darth Maul, Bib Fortuna, Ayla Secura, Dud Bolt, Gasgano, Ben Quadinaros, Mace Windu, Ki-Adi-Mundi, Kit Fisto, Eeth Koth, Adi Gallia, Saesee Tiin, Yarael Poof, Plo Koon, Mas Amedda, Gregar Typho, Cordu, Cliegg Lars, Poggle the Lesser, Luminara Unduli, Barriss Offee, Dormu, Dooku, Bail Prestor Organa, Jango Fett, Zam Wesell, Dexter Jettster, Lama Su, Taun We, Jocasta Nu, Ratts Tyerell, R4-P17, Wat Tambor, San Hill, Shaak Ti, Grievous, Tarfful, Raymus Antilles, Sly Moore, Tion Medon, Finn, Rey, Poe Dameron, BB8, Captain Phasma, Padme Amidala'



 

if __name__ == "__main__":

   main()

 

Your output should look like the following:
['C-3PO', 'R2-D2', 'R5-D4', 'Chewbacca', 'Greedo', 'Yoda', 'Palpatine', 'IG-88', 'Bossk', 'Lobot', 'Ackbar', 'Watto', 'Sebulba', 'Gasgano', 'Ki-Adi-Mundi', 'Cordu', 'Dormu', 'Dooku', 'R4-P17', 'Grievous', 'Tarfful', 'Finn', 'Rey', 'BB8']







Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

def main names Luke Skywalker C3PO R2D2 Darth Vader Leia Organa Owen Lars Beru Whitesun lars R5D4 Bi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!