Python Forum
Getting an error while using input function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting an error while using input function
#1
color = input("enter a color: ")
plural_noun = input("Enter a plural noun : ")
celebrity = input("Enter a celebrity: ")

print("roses are {color}")
print("{plural_noun) are blue")
print("i love {celebrity}")
This is the traceback i get

Error:
/Users/dharamchandsethia/PycharmProjects/Volatility/venv/bin/python /Users/dharamchandsethia/PycharmProjects/Volatility/Test.py enter a color: red Traceback (most recent call last): File "/Users/dharamchandsethia/PycharmProjects/Volatility/Test.py", line 1, in <module> color = input("enter a color: ") File "<string>", line 1, in <module> NameError: name 'red' is not defined
Do i need to define the variable color before or i can ask for user input.
Reply


Messages In This Thread
Getting an error while using input function - by dcsethia - May-11-2020, 01:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  difference between forms of input a list to function akbarza 6 1,031 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 1,088 Dec-25-2022, 03:00 PM
Last Post: askfriends
  Error in Using INPUT statement gunwaba 1 2,083 Jul-03-2022, 10:22 PM
Last Post: deanhystad
  Showing an empty chart, then input data via function kgall89 0 979 Jun-02-2022, 01:53 AM
Last Post: kgall89
  input function question barryjo 12 2,714 Jan-18-2022, 12:11 AM
Last Post: barryjo
  function with 'self' input parameter errors out with and without 'self' called dford 12 3,127 Jan-15-2022, 06:07 PM
Last Post: deanhystad
  Problem with input after function luilong 10 4,094 Dec-04-2021, 12:16 AM
Last Post: luilong
  Exit function from nested function based on user input Turtle 5 2,905 Oct-10-2021, 12:55 AM
Last Post: Turtle
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 1,973 Oct-06-2021, 09:39 AM
Last Post: menator01
  Input function cutting off commands at spaces. throwaway34 3 2,207 May-12-2021, 06:40 AM
Last Post: throwaway34

Forum Jump:

User Panel Messages

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