为什么错了
12行ten_things = "Apples Oranges Crows Telephone Light Sugar"print("Wait there are not 10 things in that list.Let's fix that.")
stuff = ten_things.split(' ')
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Gril", "Boy"]
for stuff in range(0,11):
next_one = more_stuff.pop()
print("Adding:", next_one)
stuff.append(next_one)
print(f"There are {len(stuff)} items now.")
print("There we go: ", stuff)
print("Let's do some things with stuff.")
print(stuff)
print(stuff[-1])# whoa! fancy
print(stuff.pop())
print(' '.join(stuff)) # what? cool!
print('#'.join(stuff)) # super stellar!
问题出在第 5 行和第 9 行(到底你的 stuff 是列表还是元素?系统被你搞傻了) 傻眼貓咪 发表于 2021-11-13 21:09
问题出在第 5 行和第 9 行(到底你的 stuff 是列表还是元素?系统被你搞傻了)
那我应该怎么改呢,我是想用for来输出这个列表,第五行不变的情况下应该怎么改正啊 华文杉 发表于 2021-11-13 21:16
那我应该怎么改呢,我是想用for来输出这个列表,第五行不变的情况下应该怎么改正啊
不明白,你希望输出的是? 傻眼貓咪 发表于 2021-11-13 21:21
不明白,你希望输出的是?
Wait there are not 10 things in that list.Let's fix that.
Adding: Boy
There are 7 items now.
Adding: Gril
There are 8 items now.
Adding: Banana
There are 9 items now.
Adding: Corn
There are 10 items now.
There we go:['Apples', 'Oranges', 'Crows', 'Telephone', 'Light', 'Sugar', 'Boy', 'Gril', 'Banana', 'Corn']
Let's do some things with stuff.
Oranges
Corn
Corn
Apples Oranges Crows Telephone Light Sugar Boy Gril Banana
Telephone#Light 傻眼貓咪 发表于 2021-11-13 21:09
问题出在第 5 行和第 9 行(到底你的 stuff 是列表还是元素?系统被你搞傻了)
我感觉我又行了!ten_things = "Apples Oranges Crows Telephone Light Sugar"
print("Wait there are not 10 things in that list.Let's fix that.")
stuff = ten_things.split(' ')
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Gril", "Boy"]
app = []
app != 10
for stuff in app:
next_one = more_stuff.pop()
print("Adding:", next_one)
stuff.append(next_one)
print(f"There are {len(stuff)} items now.")
print("There we go: ", stuff)
print("Let's do some things with stuff.")
print(stuff)
print(stuff[-1])# whoa! fancy
print(stuff.pop())
print(' '.join(stuff)) # what? cool!
print('#'.join(stuff)) # super stellar! 傻眼貓咪 发表于 2021-11-13 21:21
不明白,你希望输出的是?
输出这个Wait there are not 10 things in that list.Let's fix that.
There we go:['Apples', 'Oranges', 'Crows', 'Telephone', 'Light', 'Sugar']
Let's do some things with stuff.
Oranges
Sugar
Sugar
Apples Oranges Crows Telephone Light
Telephone#Light 华文杉 发表于 2021-11-13 21:24
Wait there are not 10 things in that list.Let's fix that.
Adding: Boy
There are 7 items now.
不知道是不是你要的代码:arr = ['Apples', 'Oranges', 'Crows', 'Telephone', 'Light', 'Sugar']
adding = list(map(lambda x: x, input().split()))
arr += adding
print(*arr)输出:Apples Oranges Crows Telephone Light Sugar Boy Gril Banana
页:
[1]