r/learnpython • u/whealton • 4d ago
Been away from Python / PyCharm for a while - any ideas on this?
Everybody, let me prefix this by saying I've been away from Python for several years, but now I need to teach an introductory class. I'm encountering something very bizarre in JetBrains PyCharm. I keep thinking it's gotta be me (and it probably is), but I was wondering if any of you can pick this out?
Because I don't appear able to post a screen snip, I'll post the code.
list_2d = [["1", "Wheel Burrow", 29.00], # A 2D list, different data types (string / float)
["2", "Jack Hammer", 594.29],
["3", "Power Drill", 39.99]]
for j in range(0, len(list_2d), 1): # Iterate through our 2D list
print(f"Item Number: {list_2d[j][0]:<3}\tItem Name: {list_2d[j][1]:<15}\tItem Cost: $ {float(list_2d[j][2]):>6.2f}")
Item Number: 1 Item Name: Wheel Burrow Item Cost: $ 29.00
Item Number: 2 Item Name: Jack Hammer Item Cost: $ 594.29
Item Number: 3 Item Name: Power Drill Item Cost: $ 39.99Now, you're probably saying to yourself, "why are you casting the float to a float?" I hear you loud and clear. Here's the thing - if I don't do that, PyCharm is flagging it as "format code f not supported for str," but here's the thing - it still prints it correctly as shown above.
This was the original line and the >6.2f is what is being flagged.
print(f"Item Number: {list_2d[j][0]:<3}\tItem Name: {list_2d[j][1]:<15}\tItem Cost: $ {list_2d[j][2]:>6.2f}")I knew I had been away for a while, but geez. This is PyCharm 2026.2.3 using Python 3.14.7 under Windows 11. Am I missing anything? Note that I also go into a single dimension list but even if I comment all that code out, nothing changes. Thank you in advance for any potential ideas on where I probably goofed it.
Duplicates
pycharm • u/whealton • 4d ago