12.26 python learning Notes

1 with a double loop output F

numbers = [5,2,5,2,2]
for item in numbers:
    output = ''
    for count in range(item):
        output += "x"
    print(output)

 

 

2. Find the list of the largest number

numbers = [3,6,2,8,4,20]
max = numbers[0]
for number in numbers:
    if number > max:
        max = number
print(max)

3. Delete the list of the number of repeat

numbers = [2,2,4,6,3,4,6,1]
uniques = []
for number in numbers:
    if number not in uniques:
        uniques.append(number)
print(uniques)

uniques.append () - Add a number in the table (at the end)

uniques.insert (1,19) - this number is inserted at a position 19

uniques.clear () - clear the table unit

uniques.sort () - in ascending order

uniques.reverse () - are arranged from small hit

uniques.remove (A) - A is removed from the table

uniques.pop () - remove the last item

uniques.index (A) - find the index position A

uniques.count (A) - A table has several

uniques.copy () - Creates a copy (both independent changes do not affect each other)

Guess you like

Origin www.cnblogs.com/zuotianmeichifan/p/12104944.html