Python Programming Tutorial - 28 - Default Parameters
Top Comments
All Comments (62)
-
@nilabjo2008 it must be 1/1 so people have only 2 choices
umm welcome to the future
-
@PeyamCham thank you a lot, I really haven't seen my spelling failure
-
How do you do this on Python 3+? mine says 'unsupported operand type(s) for %: 'non type' and 'tuple'' Please help.
-
@harito94 you spelled "first" wrong..
take a look at your first line...
you have def name(fisrt=......)
it should be "first"
-
-
hey, can someone say me why this is happening . This is the source code of the program:
def name(fisrt='john', last='smith'): print '%s %s' % (first,last)
name() And this the output: Traceback (most recent call last): File "C:/Users/Vision/Desktop/1.py"
, line 2, in name print '%s %s' % (first,last) NameError: global name 'first' is not defined
I'm using python 2.7.2
-
@Colstonewall %s %s mean first and last strings of "bucky","roberts" so the first and last strings are bucky roberts
-
@Colstonewall Look up a vid on python print formatting or string formatting. Basically the '%s's means that there is going to be something that the programmer will define at that part in the string. The percent sign is telling the print function that it is going to be formatting, and the part in the parenthesis defines what the '%s's are. The first %s is for the value stored in 'first' and the second %s is the value stored in 'last'. Hope that helped, though I'm sure you know by now. MONTH LATE
-
for those who use 3.2 u can do this tutorial like this :
def name (first,last): print ('%s %s' % (first,last))
follow rest of video by using it : ) give me green so rest can c it ;p
- Loading comment...
your tuts are gr8, keep it up. 5/5*
nilabjo2008 2 years ago 73
First, and yet another great vid. Keep 'em up :)
YouGotTeaBagged 2 years ago 49