Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why wont this work?
#7
Just some comments:

from random import *
Python documentation:

Quote:This imports all names except those beginning with an underscore (_). In most cases Python programmers do not use this facility since it introduces an unknown set of names into the interpreter, possibly hiding some things you have already defined.

Note that in general the practice of importing * from a module or package is frowned upon, since it often causes poorly readable code. However, it is okay to use it to save typing in interactive sessions.

if user_input not in list(glossary):
glossary is dictionary and there is no need to convert into list:

if user_input not in glossary:
f-strings are available for many years now so instead of:

'The definition of ' + user_input + ' is ' + glossary[user_input]
one can write:

f'The definition of {user_input} is {glossary[user_input]}'
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
Why wont this work? - by samh625 - Jul-30-2020, 04:53 PM
RE: Why wont this work? - by Yoriz - Jul-30-2020, 04:59 PM
RE: Why wont this work? - by ndc85430 - Jul-30-2020, 05:00 PM
RE: Why wont this work? - by samh625 - Jul-30-2020, 05:18 PM
RE: Why wont this work? - by deanhystad - Jul-30-2020, 07:44 PM
RE: Why wont this work? - by samh625 - Jul-30-2020, 07:53 PM
RE: Why wont this work? - by perfringo - Jul-30-2020, 08:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  my simple code wont work! help! simon12323121 2 2,071 Sep-05-2021, 09:06 AM
Last Post: naughtyCat
  MyProgrammingLab wont accept anything I put in chicks4 2 11,660 Feb-10-2019, 11:44 PM
Last Post: chicks4

Forum Jump:

User Panel Messages

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