Home python строка не найдена

# строка не найдена

Author

Date

Category

I study sorting by a bubble for lists.
Tell me how to calculate the number of iterations in the for:

cycle

``````list_for_sorting = [20, -34, -42, 4, -20, -20, 29, 16, 79 ]
DEF Sorting (New_List):
Last_Item = Len (new_list) -1
For i in Range (0, Last_Item):
# PRINT (new_list)
For x in Range (0, Last_Item):
IF new_list [x] & gt; new_list [x + 1]:
new_list [x], new_list [x + 1] = new_list [x + 1], new_list [x]
Return new_list.
Print ('Original List:', List_for_sorting)
new_list = Sorting (List_For_Sorting) .Copy ()
Print ('Sorting List:', new_list)
``````

``````a = [1, 2nd, 3, 4, 5]
result = {"Iteration_Number_For_Main_loop": 0}
For i in a:
Result ["Iteration_Number_For_Main_loop"] + = 1
Key = "Iteration_Number_For_loop_With_Value = {}". Format (I)
Value = 0.
For j in a:
Value + = 1
Result [Key] = Value
For X, Y in Result.iterItems ():
Print "{0}: {1}". Format (X, Y)
print "sum:", sum (result.values ​​())
# Iteration_number_for_loop_with_value = 4: 5
# Iteration_number_for_loop_with_value = 5: 5
# Iteration_number_for_loop_with_value = 1: 5
# Iteration_number_for_loop_with_value = 2: 5
# Iteration_number_for_loop_with_value = 3: 5
#iteration_number_for_main_loop: 5
#sum: 30
``````

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.