Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Input function
#1
Hi,

I am new user for python and im currently following a PDF for samples. I'm stuck where the function ( input is not working ).

code is
message = input("Tell me something, and I will repeat it back to you: ")
print(message)
please help.
deanhystad write Sep-14-2024, 12:55 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Are you running this as a script, or typing it directly into the python interpreter? It works fine when run as a script.

If you are typing in the python interpreter you need to enter the message after the input statement and before the print statement. Like this.
Output:
> python Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> message = input("Tell me something, and I will repeat it back to you: ") Tell me something, and I will repeat it back to you: this is the message >>> print(message) this is the message >>>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 2,382 Feb-21-2024, 08:02 PM
Last Post: bterwijn
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 2,371 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Showing an empty chart, then input data via function kgall89 0 1,488 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 4,597 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 7,804 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 6,092 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 4,441 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 2,763 Oct-06-2021, 09:39 AM
Last Post: menator01
  Input function cutting off commands at spaces. throwaway34 3 3,083 May-12-2021, 06:40 AM
Last Post: throwaway34
  Defining a function with input abcd 5 4,272 Feb-21-2021, 02:34 AM
Last Post: NullAdmin

Forum Jump:

User Panel Messages

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