User Profile

Collapse

Profile Sidebar

Collapse
Hichem
Hichem
Last Activity: Apr 17 '25, 11:55 AM
Joined: Apr 5 '23
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Hichem
    replied to split number on their counts in python
    To split the number correctly based on your requirement, you should use a different approach that considers the count of digits in the number. Here's a Python function that does that:
    Code:
    def split_number(number, linecnt):
        number_str = str(number)
        result = []
        
        if linecnt == 12:
            for i in range(0, len(number_str), 2):
                result.append(int(number_str[i:i+2]))
        elif
    ...
    See more | Go to post

    Leave a comment:


  • Hichem
    replied to Remove Spotify - in a string using split
    You can use the split method in Python to remove "Spotify - " from the output string. Here's how you can do it:
    Code:
    output = "Spotify - SONGNAME"
    song_name = output.split("Spotify - ")[1]
    print(song_name)
    If you want a more robust solution that ensures "Spotify - " is always removed if it exists, you can use the startswith method along with split:
    Code:
    output = "Spotify - SONGNAME"
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...