Corinne is right about Python's for repetition and how to use continue... crying

Asked 1 years ago, Updated 1 years ago, 61 views

Hello, masters Here's the question!

    numbers = [ (1,2),(10,0) ]

    for a,b in numbers:
        if b == 0:
            print("It cannot be divided by 0".")
            continue
        print("{} divided by {} is {}".format(a,b,a/b))

Problem: 'The following code accepts the tuple in number and divides the first number of tuples into the second number. If b is 0, it cannot be divided by 0. In this ifelse statement, use the continue statement to change the else to disable it.

Let me explain what I understand.

There are two tuples in the list number. In addition, forin repetitive sentences were used, and continue and format grammar were used.

The values in the list number are put into two variables, a and b and repeated.

: (Colon == then) If b is 0, output 'cannot be divided by 0'

If this is true, do continue.

So we're going back to the beginning.

Is my question, (1,2) not substituted here, but going back to the beginning of the for iteration? Or the value in the list (1,2) (executive factor) in the a and b digits from the beginning. Is argument a substitution? I don't know the order. I'm sorry I have a lot of questions. I'll help Corinne a lot when my skills get better! Thank you so much, masters. I love you!

python for continue

2022-09-22 08:19

0 Answers

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.