Skip Navigation
InitialsDiceBear„Initials” ( by „DiceBear”, licensed under „CC0 1.0” (
Posts 4
Comments 525
Could someone help me understand the input() function?
  • So what it comes down to is that int(), float(), and input() (as well as print()) are functions that you are calling. In the case of int() and float(), they return (simply put, when you make a function call it "becomes" the return value) an int or float type object based on the argument (the value between the parentheses) that you passed in. In the case of print(), it causes the program to print out the provided argument.

    input() is a little more complicated. It prints out the provided argument (in your case: Who are you? ) and then puts the program on pause while it waits for the user to input some text and press enter. Once they have done so, the input function returns the text the user has entered. So as mentioned before, the code input('Who are you? ') "becomes" the text the user input, which then gets assigned to the variable nam.

    I think where you may be getting confused is what exactly defines "text". The only things that python considers text (referred to as a string) are characters surrounded by "" or ''. In your example, input('Who are you? ') is not a string, but code to be executed (although the argument being passed to input, 'Who are you? ', is a string). As an experiment, try surrounding that code with quotation marks (name = "input('Who are you? ')") and see what happens!

  • Surface Linux question
  • I've been using PopOs on my surface for ages, but I'm not sure how much help I'd be since mine is a Surface Pro 3... I do believe, as the other person said, that you no longer need a custom kennel for things to work

  • Why does my phone already know my neighbor's number?

    I just met my new neighbor for the first time, and when we exchanged numbers (by me texting her number) my phone (Pixel 8) showed her full name with a tilde in front of it below the phone number. She's not in my contacts. Where did it get that name from?


    Want to go again?

    Image shows a post with the title "For all those right-wingers who want 'Civil War':" and the body "Your leaders are already surrendering in Atlanta again. How many times do you want to do this?".