Git Product home page Git Product logo

Comments (3)

jaime719 avatar jaime719 commented on May 29, 2024

raceback (most recent call last):

File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)

File ~/expenses.tracker.py:67
main()

File ~/expenses.tracker.py:17 in main
print(expense)

File ~/expense.py:17 in repr
return f"Expense, {self.name}, {self.category}, ${self.amount:.2f}"

ValueError: Unknown format code 'f' for object of type 'str'

from spyder.

jaime719 avatar jaime719 commented on May 29, 2024

Someone can help me out with these error

from spyder.

ccordoba12 avatar ccordoba12 commented on May 29, 2024

Hey @jaime719, thanks for reporting. I think the problem is this part of your f-string:

${self.amount:.2f}

Most probably self.amount is not a number in your code (i.e. an integer or float in your code) but a string. And that's why Python can't get two decimals of a string to print it along with your other attributes (i.e. self.name and self.category).

Let us know if that helps you to solve this problem.

from spyder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.