1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to print int in print?

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    I want to print the price of the car out. When executed I get an error:


    only strings can be concatenated in print stement
    ​

    Here is my code:

    class Board:
    def __init__(x1,car,price):
    x1.car=car
    x1.price=price
    def init1(x1):
    print("They brought a car "+x1.car +"for rupees" x1.price) ### this is where I need the print of price .
    y=Board("xylo",2000)
    y.init1()


    The expected output:


    They bought a car xylo for rupees 2000
    ​

    Continue reading...

Compartilhe esta Página