Is it not possible to uses f-string with classes

Im playing around with classes in ex37

class doorframework:
    height = 180
    width = 80
    open = False
    color = 'Red'

door1 = doorframework()
door2 = doorframework()

door2.color = 'Blue' = True


print(f"Door 1 is {door1.color}, but is it closed? {}")

However the last print statement does not work.
Is it not possible to use an f string with a class?

Hello @ktrager

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.

1 Like

There’s nothing wrong with your code. I just cut and pasted into an offline Python 3.4 iOS app and the output works fine.

Check Python isn’t v2 S @ulfen69 suggests.

1 Like

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.

1 Like

@ulfen69 & @gpkesley

I think I must have forgotten the 3.6 after python. As it definitely works now.
Sorry, it was a pretty stupid mistake.

Sorry forgot about that.
I was just so sure it should work that I got a bit head over heel to figure out if I was doing something completely wrong.

Turned out I didn’t call the the right Python version :exploding_head: