-1
Hello, I’m new to Pyhon...
I have a class called Car, and in it I have a method called name that returns the name of my object. Ex.: carro_1.name() = returns the name of the car.
I have the objects, carro_1, carro_2, carro_3...
Running carro_1.name() I get the name of the car.
I have a list with prices of all cars, in order, price in position 1 is for the carro_1, position 2 is for the carro_2 etc
I found the lowest price on my list and your position.
with this I concatenei 'carro_' + 'position + 1 ' For example: the lowest price is in heading 0 concatenei: 'carro_' + '1', got 'carro_1'
only that I’m having trouble accessing the name() method referring to the string I got.
Yes, but that doesn’t have to be done. There are better ways to manage this dynamic access to object functions. Could [Dit] the question and add an example to better understand what you are trying to do?
– Woss
I edited, please see if it’s clearer.
– Lucas Freitas
And how is this price list generated? Why is this price not part of the car object itself?
– Woss
the price is generated by the user, because it has some variables in the generation of prices.. But I would know a way for me to access the object the way I’m doing, or a similar way.
– Lucas Freitas
Use a string to call an object of the same name.
– Lucas Freitas