f-string works fine in classes too.
Just make sure you run the code with at least Python3.6
Another thing you should have in mind is the name of classes.
They should start with an upper case letter.
It makes it easier to distinguish from methods and functions in your code.
The thing you’re missing from your post is how it does not work. You’ll need to post a paste of the output inside the [code]...[/code] blocks so we can see what’s going on. It also helps to give out what you expected it to do if it’s not doing what you want.