Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyBoolNone
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.6.9 #PyBoolNone #append() and len() methods' credit goes to pythontutorial.net. Modifications and rest of the code created by Rezaul Hoque on March 14,2022. #contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; def append(item, basket=None): if basket is None: basket = [] basket.append(item) return basket basket=['soap','milk','toothpaste'] append('shampoo',basket) #if __len__() is zero bool() constructor returns false otherwise it returns true if basket is not None and len(basket) > 0: for element in basket: print(element) else: print('Basket is empty')
[
+
]
Show input
Absolute running time: 0.16 sec, cpu time: 0.03 sec, memory peak: 8 Mb, absolute service time: 0,19 sec
edit mode
|
history
|
discussion
soap milk toothpaste shampoo