Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I split the output?
Quick and easy question, I am sure. I am creating two lists and then taking one item from each list to create a separate list. When I run the program the output doesn't come out as two different items, only in one item. How do I split the output into two items? It outputs "ESPFender" right now and I want "ESP" "Fender". Thank you!

fave_guitars = ["ESP", "Breedlove", "Ibanez"]
bad_guitars = ["Gibson", "Fender", "Jackson"]

fave_and_least = fave_guitars[0] + bad_guitars[1]

# Join elements with a space (nice for a long list)
fave_and_least = " ".join(fave_guitars[0], bad_guitars[1])
# Just toss in a space
fave_and_least = fave_guitars[0] + " " + bad_guitars[1]
# Use a f-string for formatting and have a space between the elements
fave_and_least = f"{fave_guitars[0]} {bad_guitars[1]}"
nilamo and AnunnakiKungFu like this post
Thank you very much!

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Split Output Audio on Text to Speech Code Base12 2 3,581 Aug-29-2020, 03:23 AM
Last Post: Base12
  [split] No Error, and No Output vishal2894 1 730 Jul-02-2019, 03:20 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020