Added: 2 years ago
From: thenewboston
Views: 42,809
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (61)

Sign In or Sign Up now to post a comment!
  • How do you do this on Python 3+? mine says 'unsupported operand type(s) for %: 'non type' and 'tuple'' Please help.

  • 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

  • Comment removed

  • @harito94

    typo: def name(fisrt='john') should be def name(first='john')

  • @harito94 you spelled "first" wrong..

    take a look at your first line...

    you have def name(fisrt=......)

    it should be "first"

  • @PeyamCham thank you a lot, I really haven't seen my spelling failure

  • 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

  • python is simple language

    and i hope it's will be simple exam too

  • The 1st part of the vid sorta confused me. I don't quite understand the print '%s %s' % (first,last). . .When did we learn that? I know vid #17 showed using the %s in a string & using % then the variable name, but I don't understand that part. Why are the %s in single quotes? And why % (first,last)??

  • @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

  • @Colstonewall %s %s mean first and last strings of "bucky","roberts" so the first and last strings are bucky roberts

  • Who are the two people who keep on disliking this video? Its annoying me

  • Reached 28! Almost to 30 :D

  • Comment removed

  • Comment removed

  • for some reason the create a function is giving my a syntax error in 3.2 anyone know how to fix?

  • @skaneification download 2.7.1 and it'll fix it.

  • @skaneification 3.2 is not good right now so not many peope teach it the reason is that being so new it is not suppored with all of it's libs so use 2.6 or 2.7 for now and things will always work for you in these tuts

  • good job theres no voice crack at the end!

  • I did "return" instead of "print" since this is a function. I wonder if it's just like java, where whenever your just want to print you don't have to return...

  • So I guess there's no operator overloading in python?

  • fantastic job on these tutes (y)

  • what if ur name is Tom Smith :P

  • @randomking333 then you don't have as much work ;)

  • 1 person doesn't know python

  • Each time I go on to the next tutorial, I see less and less viewers. Thumbs up for sticking with it and not giving up! WE ARE THE SURVIVORS!

  • @12345678910secret it's not about that , some people look for something in python , they just watch the video they need

  • @TheADMIRAL911 How would that explain the fact that there are less viewers on each video?

  • Isn't it easier to just:

    def name(first,last): print first, last

    ???

    Without the "%s %s".

  • @tonyram19 in this case yes, but in other cases nope :)

  • @paraphernailia How come?

  • @tonyram19 Basically to put it short, when u use more complex and longer scripts, this will be easier, if you stick with python, you will find out yourself :)

  • you didn't explained more about the %s here D:! I know a bit about the %s from tutorial 17 but not fully :(

  • I love how as tutorials go more complex, they have less viewers xP

  • Hey Bucky do you have any tutorials out there that help with a programming a program assignment from start to finish?

  • @TopOfDaWall I can help cha :D

  • for python 3

    def name(first,last): print ('%s %s' % (first, last))

  • very interesting. i can't wait to populate data bases!

  • for those of you using python 3.0, it uses different syntax in some cases. look up a python 3.0 tutorial.

  • Thank you very much for this tutorial.

  • this one also isnt working on python 3.0 =(

  • thanks man

  • Thank you very much.

  • The correct title is actually "default arguments" as an argument is the value, a parameter is the name.

  • why use the %s ? it works just as good without them. just writing print first, last?

  • if you use: print first + last, there wont be the space in the middle of the 2 words.

    >>>name('bucky', 'roberts')

    buckyroberts *instead ot bucky roberts*

  • I didnt even remember I asked this :P I figured that you dont have too put the ( ) signs in the printstatement, cause without them you dont need the %s. thats probably it :)

  • @jellene4eva u could just do "first + ' ' + last" but the way he did it is probably more efficient and easier to read for most python users

  • Still Great :D

  • great job keep it up

  • Thank you alot ;)

  • Good tutorial

  • your tuts are gr8, keep it up. 5/5*

  • First, and yet another great vid. Keep 'em up :)

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more