Python Forum
Replacing all letters in a string apart from the first letter in each word
Thread Rating:
  • 4 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replacing all letters in a string apart from the first letter in each word
#7
Do i have to be on a specific version of python for this to work because i literally pasted the code you put in into a new python doc and im still getting the error, do i need to import anything?
def test(song_name):
    return ' '.join([f--------->'{word[0]}{(len(word) - 1) * " _ "}'<--------- for word in song_name.split()])
 
print(test("Nothing Else Matters"))
Where i have put the arrows is where the error is happening
Reply


Messages In This Thread
RE: Replacing all letters in a string apart from the first letter in each word - by Carbonix - Jan-17-2019, 09:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Retrieve word from string knob 4 534 Jan-22-2024, 06:40 PM
Last Post: Pedroski55
  extract substring from a string before a word !! evilcode1 3 583 Nov-08-2023, 12:18 AM
Last Post: evilcode1
  Replacing String Variable with a new String Name kevv11 2 815 Jul-29-2023, 12:03 PM
Last Post: snippsat
  Help replacing word in Mutiple files. (SOLVED) mm309d 0 871 Mar-21-2023, 03:43 AM
Last Post: mm309d
  Isolate a word from a long string nicocorico 2 1,569 Feb-25-2022, 01:12 PM
Last Post: nicocorico
  change string in MS word Mr_Blue 8 3,424 Sep-19-2021, 02:13 PM
Last Post: snippsat
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,556 Aug-12-2021, 04:25 PM
Last Post: palladium
  Trying to get the first letter of every word in a list DanielCook 2 2,184 Jan-05-2021, 05:06 PM
Last Post: deanhystad
  Replacing a words' letters in a string cananb 2 3,510 Dec-01-2020, 06:33 PM
Last Post: perfringo
  Trying to find first 2 letter word in a list of words Oldman45 7 3,808 Aug-11-2020, 08:59 AM
Last Post: Oldman45

Forum Jump:

User Panel Messages

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