Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input function
#7
jefsummers provided way to learn definitions of functions you need to use. This is valuable knowledge - how to access built-in help of Python. It takes some practice to develop skills for comprehending information which help provides (and this is what learning is all about).

It seems to me that some examples how to use input() can help in learning process. In interactive interpreter:

>>> input('What is your name? ')              # ask for name
What is your name? Bob                        # input the name
'Bob'                                         # name is displayed but it's gone after that
>>> name = input('What is your name? ')       # in order to use name later, we assign it to name
What is your name? Bob
>>> name                                      # now we can use name whenever we need
'Bob'
>>> profession = input('What is your profession? ') # let' ask some more and assign
What is your profession? The Builder
>>> profession                                 
'The Builder' 
>>> title = f'{name} {profession}'            # let's use these values to create new value
>>> title
'Bob The Builder'
Just keep in mind that input always returns str, so if you want to make calculations conversion is needed.
jefsummers and soupworks like this post
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Input function - by Fabio87 - Dec-19-2020, 11:16 AM
RE: Input function - by buran - Dec-19-2020, 11:28 AM
RE: Input function - by Fabio87 - Dec-19-2020, 05:40 PM
RE: Input function - by PyMahan - Dec-26-2020, 07:21 PM
RE: Input function - by jefsummers - Dec-19-2020, 01:33 PM
RE: Input function - by ndc85430 - Dec-19-2020, 05:50 PM
RE: Input function - by jefsummers - Dec-20-2020, 08:45 PM
RE: Input function - by perfringo - Dec-21-2020, 07:59 AM
RE: Input function - by Fabio87 - Dec-23-2020, 05:36 PM
RE: Input function - by jonny0000 - Jan-02-2021, 08:13 AM
RE: Input function - by gruntfutuk - Jan-09-2021, 11:36 AM
RE: Input function - by Alex143 - Apr-29-2022, 03:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to print the docstring(documentation string) of the input function ? Kishore_Bill 1 3,673 Feb-27-2020, 09:22 AM
Last Post: buran
  Writing a function that changes its answer based on user input SirRavenclaw 2 2,971 Dec-21-2019, 09:46 PM
Last Post: Clunk_Head
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,620 Mar-23-2019, 06:54 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020