Python Forum

Full Version: I am getting an IndentError on my python code in VS Code and i dont know why
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Indentation issues can be tricky in Python. It’s best to stick to either tabs or spaces consistently. You can set your editor to convert tabs to spaces to avoid this problem in the future.
I only use Idle to try things out. The following works fine in Idle.

carros = ["mercedes", "toyota", "mazda", "bmw", "nissan", "hyundai", "byd"]
colores = ['blanco', 'negro', 'rojo', 'amarillo', 'gris', 'verde', 'marrón']

for i in range(len(carros)):
    car = carros[i].capitalize()
    if len(car) == 3:
        car = car.upper()
    print(f"¡No me gusta tu {car} en nada, es un trasto tío!")
    print(f"¡Además odio ese color {colores[i].title()} ¡Que marrón!\n")
Pages: 1 2