0

I am building a song metadata library and the f string keeps returning a new line on the BPM String I added:

def all(self):
    return '{} {} {} {} {} {} {} {} {} {} {}'.format(self.title, 
        self.length, 
        self.scale, 
        (f"{self.bpm} BPM"), 
        self.timesignature, 
        self.lyrics, 
        self.start, 
        self.end, 
        self.release, 
        self.album,  
        self.notes)

How do I keep the BPM string on the same line?

This is the output:

 Incunabula

 3:21
 C Aeolian
 69 
 BPM 4/4

BPM should be right after the 69.

1 Answers1

1

As identified by @Selcuk, some of your strings contains whitespaces.

You can strip whitespaces (that includes newline) by using str.strip(). It removes surrounding whitespaces (before or after the string)

In your case, you can replace your BPM line (or any line that has whitespaces around it) with this.

...
(f"{self.bpm.strip()} BPM"), 
...
Rahul
  • 10,830
  • 4
  • 53
  • 88