```#coding=utf-8
list=[]
for i in range(1,101):
list.append(i)
# print(list)
tempList=[]
newList=[]
while True:
num=0
for temp in list:
tempList.append(temp)
num+=1
if num==3:
newList.append(tempList)
tempList=[]
num=0
continue
if temp==100:
newList.append(tempList)
break
print(newList)```

Output ：

`[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24],.......[100]]`
```oldList=[x for x in range(1,101)]
newList=[oldList[x:x+3] for x in range(0,len(oldList),3)]
print(newList)```

Output ：

`[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24],.......[100]]`
```def f(x,y,z):
return x,y,z
m = list(map(f, [x for x in range(1,101,3)], [y for y in range(2,101,3)], [z for z in range(3,101,3)]))
print(list(m))```

Output ：

`[(1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12), (13, 14, 15), (16, 17, 18), (19, 20, 21), (22, 23, 24),......(100)]`

There are many other similar methods , More research is needed

Python More related articles about list nesting in various ways

1. python List nesting

>>> a = ['a', 'b', 'c'] >>> n = [, , ] >>> x = [a, n] >>> x [[, ...

2. Python The addition and deletion of the list changes the special output format of nesting

Python The addition and deletion of the list changes the special output format of nesting One . The list looks like : a = ['q' , 'w' , 'e ', 'r','t'] a Name the list ,[ ] For list content ,' ' For the elements in the list ,'q' by a[0] Two ...

3. python About dictionary nesting dictionary , List nested dictionaries sort by value

python For dictionaries nested Dictionaries , List nested dictionary sort example : List nested from dictionary :d = [{"name": ' Zhang San ', 's': 68}, {'name': ' Li Si ', 's': 97}] ...

4. python Three ways of traversing list and string in reverse order

python Three ways of traversing list and string in reverse order Reverse traversal of list a = [1,3,6,8,9] print(" Traversal in reverse order by subscript 1:") for i in a[::-1]: print( ...

5. python Nested list into dictionary unicode String conversion to str The method of creating a string of format

It's going on today django There is a very difficult problem in the process of development , Because of demand , A copy of the data needs to be saved as json Format to database , This format is as follows : list_1 = [{"name":&q ...

6. Python List derivation and nested list derivation

List derivation provides a simpler way to create a list . A common use is to apply an operation to each element of a sequence or iteratable object , Then use its results to create a list , Or create subsequences by satisfying certain conditional elements . for example , Suppose we want to create a square ...

7. python The whole development of the stack _day8_ Various ways of reading and writing files and cursors

One : Multiple ways of reading and writing files Main mode :w    r    a From the way :t     b    + How to understand :x    u 1) Press t( Operate according to characters ): with open("data_1.txt& ...

8. python Lists and strings 、 The difference of tuples and the way of list reference

One . character string Strings can also be valued with subscripts . section .for loop .len() Take the length and in and not in To operate . But strings are immutable , Can't be changed . Only one can be constructed “ new ” String to access the data you want to modify . ...

9. Python How to deal with nested list in list

When dealing with lists, we often encounter the structure of nested lists in the list , If we want to put all the elements in a new list , Or how to calculate the number of all elements ? First example For such a set of data in the figure above , If we want to know this CSV In file ...

Random recommendation

1. Mysql in show full processlist

processlist The output of the command shows which threads are running , It can help identify problematic query statements , Use this command in two ways . 1. Get into MySQL/bin Enter... In the directory mysqladmin processlist; ...

2. I2C The driver

i2c_add_driver i2c_register_driver driver->driver.bus = &i2c_bus_type; driver_register(&d ...

3. Java Development Notes （ forty-three ） Better use of local date and time

Words Java Two sets of time tools were designed in a row , They are date type Date, And calendar type Calendar, Reasonably speaking, it is more than enough for coding development . However, as Java More and more widely used , People still find their disadvantages . Not to mention congenital defects ...

4. 14. Longest Common Prefix *

Topic content :Write a function to find the longest common prefix string amongst an array of strings Topic analysis : Benefit of the subject ...

5. php Create transparent background in png Thumbnail program

/** *\$sourePic: The original path  * \$smallFileName: Sketch name  * \$width: Small chart width  * \$heigh: Small picture height  */function pngthumb(\$sourePic,\$s ...

6. JAVA And Math ***

Math Many methods are defined in , And these methods are simple static type , adopt Math Class can be called directly . Call form :Math. Method name for example , I'm going to do it e operation , So I call it directly Math.exp(double type The number ); ...

7. 44 individual Java Summary of code performance optimization

https://blog.csdn.net/xiang__liu/article/details/79321639 --- I'll have time to sort it out later

8. CF 987

Cancer Although the ranking is not bad ,331, however B I didn't do it ...... This is a record : You can see that I'm very powerful A 了 CDE, however B Stuck me three times ... Or I'll get in the front 300 了 ( It's still very watery ). Analyze the topics one by one : ...

9. spring boot JedisCluster Connect redis Cluster configuration

The configuration file Configuration class At the time of construction , You can look at it , Only Set<HostAndPort> Parameter is required Made a layer of encapsulation , Easier to use result

10. JSP Realize data saving (web Basic study notes 4 )

session object : // Server settings Session attribute session.setAttribute("user", username); // Client reception Session Object ...