+ 2

What is the use of pass statement in python

it belongs to conditional statements

20th Jul 2017, 4:09 PM
SaiKumar
SaiKumar - avatar
4 Antworten
+ 7
Nothing happens when pass executes, so you can use it for things like a placeholder for a function that is defined but does not have any code yet or to ignore errors in a try-except codeblock by adding 'pass' to the except block (:
20th Jul 2017, 5:34 PM
Maya
Maya - avatar
+ 6
pass tells python to skip that line and continue. for example: if True: pass else: print("Hi") #Output: Nothing example 2: if True: print("Before pass") pass print("After pass") else: print("else") #output: Before pass After pass
20th Jul 2017, 5:33 PM
Sapphire
+ 1
OK I understood when pass executes nothing happens in the program.
21st Jul 2017, 12:21 AM
SaiKumar
SaiKumar - avatar
+ 1
This example might help you. class Character(): Type = "Alien " Guns = 2 Height = 6.9 class ZombieType1(Character) : #Inheritance pass class ZombieType2(Character) : pass class ZombieType3(Character) : pass class ZombieType4(Character) : pass class ZombieBoss(Character) : Guns = 9 Height = 9.6 Zombie1 = ZombieType1() Zombie2 = ZombieType2() Boss = ZombieBoss()
21st Jul 2017, 4:41 AM
Deep chand
Deep chand - avatar