Name | return |
||||||
---|---|---|---|---|---|---|---|
Examples |
def timestwo(dVal): return dVal * 2 t = timestwo(30) print(t) # 60 def timestwo(dVals): return [x * 2 for x in dVals] t = timestwo([10, 20, 30]) print(t) # [20, 40, 60] def draw(): background(204) line(0, 0, width, height) if mousePressed: return # Break out of draw(), skipping the line statement below line(0, height, width, 0)# Executed only if mouse is not pressed | ||||||
Description |
Keyword used to indicate the value to return from a function.
The keyword return may also be used to break out of a function, thus not allowing the program to the remaining statements. (See the third example above.) |
||||||
Syntax | def function: statements return value | ||||||
Parameters |
|
Updated on Mon Sep 21 15:53:25 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License