Recently looking for a site for python language exercises, found this site is good http://www.checkio.org/
The page design is also pretty, and it is suitable for learning python syntax knowledge.
However, when registering this website, you have to solve a python problem, but it is very simple.
1 #python3.3 is inside2 def checkio(els):3 return els4 5 if checkio([1, 2, 3, 4, 5, 6]) == 6:6 print('Done!')
Modify the checkio function in the above Code so that the output is the sum of the number in front of the list.
1 def checkio (els): 2 return els [0] + els [1] + els [2] # return sum (els [0: 3]) 3 if checkio ([1, 2, 3, 4, 5, 6]) = 6 4 print ('done! ')
Simply modify one and then directly registry.
After entering the course, I felt like a zombie in the plant war.
The first question is Non-unique Elements.
Code:
temp=[]a=len(data)def checkio(data): for n in range(a): if data.count(n)>1: temp.append(data[n]) data =tempreturn data
The ranking one in creative is more creative.
def checkio(data): return([x for x in data if data.count(x)>1])
This method is more concise. You can use a for Loop in a row to add all the values to the list ..
The above is just a good website to share with you how to learn python. Low technical content, light spray.