Some people may encounter many problems when writing code. Next, let's look at how to write the relevant code. I hope you will gain some benefits in future use. The use of the Python return programming language requires constant discussion.
- # Coding: UTF-8
- Def testReturn (x ):
- If x> 10000:
- Return
- Print "test return !! "# This sentence will never be executed
- El'if x> 1000:
- Return 100
- El'if x> 100:
- Return 10
- Elif x> 10:
- Return 1
- Else:
- Return 0
- Print testReturn (9999999) # result = None
- Print testReturn (9999) # return = 100
- Print testReturn (999) # return = 10
- Print testReturn (99) # return = 1
- Print testReturn (9) # return = 0
- # Return instructions:
- # (1) return the return value of the Function
- # (2) Terminate the program and exit early
The above is an introduction to problems related to the Python return language. I hope you will have some gains.