Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
input function question
#10
I see no reason why you would ever use input() in interactive mode. I guess it kind of works but it is really awkward.

If I do this in interactive mode it appears to work (awkwardly).
Output:
>>> x = input("A") Ahi >>> print(x) hi
I can also do this which is a bit less awkward.
Output:
>>> x = input("A"); print(x) Ahi hi
It would make a lot more sense to write:
Output:
>>> x = "hi" >>> print(x) hi
But you are right that you cannot paste two lines into an interactive session and have it work.
Output:
>>> x = input("A") Aprint(x) >>> hi Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'hi' is not defined
So what is the problem?
Reply


Messages In This Thread
input function question - by barryjo - Jan-17-2022, 04:11 PM
RE: input function question - by deanhystad - Jan-17-2022, 04:24 PM
RE: input function question - by barryjo - Jan-17-2022, 04:33 PM
RE: input function question - by jefsummers - Jan-17-2022, 04:34 PM
RE: input function question - by barryjo - Jan-17-2022, 04:40 PM
RE: input function question - by BashBedlam - Jan-17-2022, 04:43 PM
RE: input function question - by barryjo - Jan-17-2022, 04:57 PM
RE: input function question - by deanhystad - Jan-17-2022, 06:26 PM
RE: input function question - by barryjo - Jan-17-2022, 07:12 PM
RE: input function question - by deanhystad - Jan-17-2022, 07:32 PM
RE: input function question - by barryjo - Jan-17-2022, 10:40 PM
RE: input function question - by deanhystad - Jan-17-2022, 11:25 PM
RE: input function question - by barryjo - Jan-18-2022, 12:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,125 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  Question on dir() function Soorya25 1 1,196 Jan-16-2023, 09:33 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 1,145 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Function not scriptable: Noob question kaega2 3 1,233 Aug-21-2022, 04:37 PM
Last Post: kaega2
  Showing an empty chart, then input data via function kgall89 0 998 Jun-02-2022, 01:53 AM
Last Post: kgall89
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,234 Jan-15-2022, 06:07 PM
Last Post: deanhystad
Big Grin General programming question (input string)[ jamie_01 2 1,642 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Problem with input after function luilong 10 4,170 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 2,976 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 2,004 Oct-06-2021, 09:39 AM
Last Post: menator01

Forum Jump:

User Panel Messages

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