Python重复的结果总是双重的

Python重复的结果总是双重的,python,for-loop,Python,For Loop,我对python还是新手。我尝试使用循环时遇到问题。我有两个变量,第二个变量总是给我相同的结果。在我的示例中,我有这样一个数据库: id | name 1 porce 2 cadilcac 3 honda 4 toyota 1.porce 2.porce 3.porce 4.porce 首先,我试着循环使用id,它工作得很好。但当我尝试循环使用名称时,结果总是错误的,如下所示: id | name 1 porce 2 cadilcac 3 honda

我对python还是新手。我尝试使用循环时遇到问题。我有两个变量,第二个变量总是给我相同的结果。在我的示例中,我有这样一个数据库:

id | name
1    porce
2    cadilcac
3    honda
4    toyota
1.porce
2.porce
3.porce
4.porce
首先,我试着循环使用
id
,它工作得很好。但当我尝试循环使用
名称
时,结果总是错误的,如下所示:

id | name
1    porce
2    cadilcac
3    honda
4    toyota
1.porce
2.porce
3.porce
4.porce
我想要的结果是:

1.porce
2.cadilcac
3.honda
4.toyota
这是我的代码:

number = 0
for id_id in id_number:
    dd = name # here i call the name by id
    number += 1
    print(number)
    print(dd)

为什么不直接使用车辆列表来循环兄弟,例如:

vehicles = ["Honda", "Porche", "Cadilcac", "Toyota"]
number = 0
for vehicle in vehicles:
    number += 1
    print(number)
    print(vehicle)
我希望有帮助:)


我希望这就是您的意思。

向您展示整个代码。您可能忘了使用正确的变量您是说保时捷?还有,什么是
名称
?对不起,您的代码没有帮助。有两个变量没有任何来源,你的评论的意思是不明确的。
vehicles = ["Honda", "Porche", "Cadilac", "Toyota"]
number = 0
for vehicle in vehicles:
    number += 1
    print(str(number) + ". " + vehicle)