Given a list of Star Wars characters, Make a second list that includes only the characters whose
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 of the new list to the screen
.Instructions
- 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.
- Make an empty Python list named single_word_names
- 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.)
- 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']
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill