Exercise 38 - list

Posted petitherisson

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Exercise 38 - list相关的知识,希望对你有一定的参考价值。

 

ten_things = "Apples Oranges Crows Telephone Light Sugar"

print("Wait there‘s not 10 things in that list, let‘s fix that.")

stuff = ten_things.split( )
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"]

while len(stuff) != 10:
    next_one = more_stuff.pop()
    print("Adding: ", next_one)
    stuff.append(next_one)
    print("There‘s %d items now." % len(stuff))
    
print("There we go:", stuff)

print("Let‘s do some things with stuff.")

print(stuff[1])
print(stuff[-1]) # whoa! fancy
print(stuff.pop())
print( .join(stuff)) # what? cool!
print(#.join(stuff[3:5])) # super stellar!

output

Wait theres not 10 things in that list, lets fix that.
Adding:  Boy
Theres 7 items now.
Adding:  Girl
Theres 8 items now.
Adding:  Banana
Theres 9 items now.
Adding:  Corn
Theres 10 items now.
There we go: [Apples, Oranges, Crows, Telephone, Light, Sugar, Boy, Girl, Banana, Corn]
Lets do some things with stuff.
Oranges
Corn
Corn
Apples Oranges Crows Telephone Light Sugar Boy Girl Banana
Telephone#Light

 

2019-10-01

01:22:22

以上是关于Exercise 38 - list的主要内容,如果未能解决你的问题,请参考以下文章

Week 3: Structured Types 5. Tuples and Lists Exercise: odd tuples

python_exercise_给定一个只包含正整数的非空数组,返回该数组中重复次数最多的前N个数字 ,返回的结果按重复次数从多到少降序排列(N不存在取值非法的情况)

xctf-WEB-新手练习区Exercise area-Writeup

xctf-WEB-新手练习区Exercise area-Writeup

TP5报如下的错误 Indirect modification of overloaded element of thinkpaginatorCollection has no effect(代码片段

第38讲:List伴生对象操作方法代码实战