Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Return a definition
#3
user_input is a string, so str(user_input) does nothing. I don't understand what you are doing with the parenthesis in this line:
# return ('The definition of') ,user_input + (glossary [user_input])
return 'The definition of ' + user_input + ' is ' + glossary [user_input]
I think a format string is a better solution (f'' or ''.format()), but you can use string concatenation if you want.
Reply


Messages In This Thread
Return a definition - by samh625 - Jul-27-2020, 10:30 AM
RE: Return a definition - by jefsummers - Jul-27-2020, 11:23 AM
RE: Return a definition - by samh625 - Jul-27-2020, 01:05 PM
RE: Return a definition - by deanhystad - Jul-27-2020, 01:04 PM
RE: Return a definition - by samh625 - Jul-28-2020, 08:32 AM
RE: Return a definition - by deanhystad - Jul-27-2020, 02:44 PM
RE: Return a definition - by jefsummers - Jul-27-2020, 09:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  New to coding. An error occurs with no definition westernwhiskey 4 3,159 Mar-15-2018, 12:37 PM
Last Post: westernwhiskey
  trouble importing class definition from one .py into another ijosefson 3 3,447 Oct-16-2017, 08:24 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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