Trying to turn the key into a variable
from sabreW4K3@lemmy.tf to python@programming.dev on 14 Jan 2024 12:51
https://lemmy.tf/post/3323775

****FIXED IT! ****

    if "TXXX:FMPS_Rating_Amarok_Score" in tags:
      rating = tags["TXXX:FMPS_Rating_Amarok_Score"]
      print([key for key in rating])
    else:
      print(" ".join(["No rating exists for",mp3_file,"this song"]))

This code snippet prints the key as [‘0.66’] That 0.66 is the exact value that I need?

A searching the internet showed me that people often want this the other way round, but no one seems to try to do what I’m doing? Does anyone have any idea on how to do it?

#python

threaded - newest

CodeMonkey@programming.dev on 16 Jan 2024 21:46 collapse

Did you find the answer to your question, and if not, could you explain it better?

Also, a quick tip: if you are using Python 3, you don’t need to join your variables before passing them into print. print accepts any number of arguments, converts them to strings, and prints them as a single line separated by spaces (which is exactly what your code seems to be doing).

sabreW4K3@lemmy.tf on 16 Jan 2024 23:11 collapse

I did indeed, it resulted in this script lemmy.tf/post/3359226

If you have any advice on how to improve it, I would greatly appreciate it.

Also, thank you for the print information. That’s really helpful.