[問題] 新手又來發問了QAQ

作者: lingze (walkman)   2014-04-01 21:31:15
list_parent_answer.append(Find_Minimum(list_parent_v1))
list_parent_answer.append(Find_Minimum(list_parent_v2))
.
.
.
list_parent_answer.append(Find_Minimum(list_parent_v10))
假如我想要做這10行,有沒有辦法用迴圈做呢?
list_parent_v1~v10 都是變數
我想要做成這樣
n=0
while(0<temp):
list_parent_answer.append(Find_Minimum(list_parent_vn))
n += 1
temp -= 1
return list_parent_answer
請問有辦法做到這樣嗎QQ?
作者: orangechin (我戀橘)   2014-04-01 21:40:00
eval("list_parent_v" + str(n))
作者: grtfor (哦啦啦)   2014-04-01 22:15:00
locals() or globals() or obj.__getattribute__()

Links booklink

Contact Us: admin [ a t ] ucptt.com