Latest
Loading...

Python for Ethical Hacking

Command Prompt

Featured Post

#5 Jarvis

Jarvis      Now we are going to create some functions. With the help of this functions we are going to make our Play music Open website...

Loop control statements || Python for beginners

Loop control statements || Python for beginners

Loop control statements


  1. Break statement       – Breaks the loop statement
  2. Continue statement – skips the loop body and continue
  3. Pass statement         – execute nothing



Break statement 

It terminates the loop and transfers execution to the next statement of the next statement of the loop immediately in the program


Syntax

          break


Example 

for letter in “S.M. Security”:

    if letter==“M”:

        break

    print(“The current letter is :”, letter)


Output

The current letter is: S

The current letter is: .


Continue statement 

The continue statement is used to skip the rest of the code inside a loop for the current iteration only. It is used to transfer the control to the beginning of the loop


Syntax

          continue


Example 

for letter in “Python”:

    if letter==“h”:

        continue 

    print(“The current letter is :”, letter)


Output

The current letter is: P

The current letter is: y

The current letter is: t

The current letter is: o

The current letter is: n


Pass statement

  • Pass statement execute nothing 
  • It results in no operation


Syntax

          pass


Example

for letter in “Python”:

    if letter==“h”:

        pass

    print(“The current letter is :”, letter)


Output

The current letter is: P

The current letter is: y

The current letter is: t

The current letter is: h

The current letter is: o

The current letter is: n






No comments:

Post a Comment