I want to have more dict's in my init.py and I want to set it's name in a variable. But it wouldn't detect it as the name.
My Program:
from StackOverflow import *
number = input("Wich car do you want:")
car = r"Car"+number
print(car["Color"])
print(car["Brand"])
StackOverflow\__init__.py:
Car1 = {
"Color": "Bleu",
"Brand": "Aston Martin"
}
Car2 = {
"Color": "Red",
"Brand": "Volvo"
}
I expect that it give the color and brand from the chosen car. But I get this error:
Traceback (most recent call last):
File "D:/Users/stanw/Documents/Projecten/Stani Bot/Programma's/StackOverflow/Choose Car.py", line 5, in <module>
print(car["Color"])
TypeError: string indices must be integers