Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 02f3e5c

Browse files
Add demo of multiple return values from function
1 parent f60fc7b commit 02f3e5c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎FunctionIntroduction/src/findprime.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def key_word_func_args(a, b, *args, **kargs):
5151
for k in kargs:
5252
print('key = {} and value = {}'.format(k, kargs[k]))
5353

54+
def func_return_multiple_val():
55+
print('Demo of returning multiple values in python')
56+
a = 1
57+
b = 2
58+
c = 3
59+
d = 'This is a string'
60+
return a, b, c, d
61+
5462
def main():
5563
for n in range(1, 20):
5664
isprime(n)
@@ -65,5 +73,9 @@ def main():
6573
arbitrary_list_arg_func_2(1, 2, 3, 4,5,6,7)
6674
print()
6775
key_word_func_args(3, 45, 1 , 2, 3, one = 1, two = 2, three = 3)
76+
print()
6877

78+
a, b, c, d = func_return_multiple_val()
79+
print('a={}, b = {}, c={}\nd={}'.format(a,b,c,d))
80+
6981
if __name__ == '__main__': main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /