Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringMethodsReview #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions StringMethods
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
highlighted_poems = "Afterimages:Audre Lorde:1997, The Shadow:William Carlos Williams:1915, Ecstasy:Gabriela Mistral:1925, Georgia Dusk:Jean Toomer:1923, Parting Before Daybreak:An Qi:2014, The Untold Want:Walt Whitman:1871, Mr. Grumpledump's Song:Shel Silverstein:2004, Angel Sound Mexico City:Carmen Boullosa:2013, In Love:Kamala Suraiyya:1965, Dream Variations:Langston Hughes:1994, Dreamwood:Adrienne Rich:1987"

# print(highlighted_poems)

highlighted_poems_list = highlighted_poems.split(",")

# print(highlighted_poems_list)

highlighted_poems_stripped = []
highlighted_poems_details = []
titles = []
poets = []
dates = []

for space in highlighted_poems_list:
highlighted_poems_stripped.append(space.strip())

# print(highlighted_poems_stripped)

for colon in highlighted_poems_stripped:
highlighted_poems_details.append(colon.split(":"))

# print(highlighted_poems_details)

for details in highlighted_poems_details:
titles.append(details[0])
poets.append(details[1])
dates.append(details[2])

# print(titles)
# print(poets)
# print(dates)

# for output in range(len(titles)):
# new_string = "The poem {titles} was published by {poets} in {dates}".format(titles = titles[output], poets = poets[output], dates = dates[output])
# print(new_string)

for output in range(len(titles)):
print(f"The poem {titles[output]} was published by {poets[output]} in {dates[output]}")