当我在答案中输入多个字母时,我的列表会出现两倍

问题描述 投票:1回答:1
item=[]

a = raw_input('enter 1st item')
for x in a :
    item.append(a)

b = raw_input('enter 2nd item')
for x in b :
    item.append(b)

c = raw_input('enter 3rd item')
for x in c :
    item.append(c)

print item
python list loops for-loop
1个回答
0
投票
    item=[]

    a = raw_input('enter 1st item')
    for x in a :
        item.append(x)

    b = raw_input('enter 2nd item')
    for x in b :
        item.append(x)

    c = raw_input('enter 3rd item')
    for x in c :
        item.append(x)

print item
© www.soinside.com 2019 - 2024. All rights reserved.