Q. Find and write the output of the following python code:


for Name in ['Jayes', 'Ramya', 'Taruna', 'Suraj'] :

    print (Name)

    if Name[0] == 'T' :

        break

    else :

        print("Finished!")

print ('Got it!')



Answer =

Jayes
Finished!
Ramya
Finished!
Taruna
Got it!

>>>

Explanation :

Iterates through the list of names: 'Jayes', 'Ramya', 'Taruna', 'Suraj'.
For each name, it prints the name.
Checks if the first letter of the current name is 'T'. If it is, the loop breaks.
If the first letter is not 'T', it prints "Finished!" after printing the name.
After the loop is finished or broken, it prints 'Got it!'

6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. suraj not taruna

    ReplyDelete
    Replies
    1. You are wrong it will taruna. If you have doubt then please run it in your pc.

      Delete
  2. Taruna
    Got it
    Suraj
    Finished!

    Is it correct

    ReplyDelete
    Replies
    1. No, You are wrong. Please copy the code and paste it in your python.

      Delete
  3. Can you explain me this code

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post