Here is my code:


The instructions are printed out from the python file.

They are given here for convienience

  1. You start by typing in a letter

  2. The computer then types another letter and the cycle repeats Example: You type: z Computer types: a

  3. You know that zambia and zaire start with ""za""." "

  4. So the next letter you type must me ""m"" or ""i"". But, you must type" """m"" because the last letter of zambia will end on the computer." On the other hand, last letter of zaire will end on you.

  5. The person on which the last letter ends, loses. Example: Computer loses on sweden You lose on dubai

  6. If you don't know any place you can type in ""Challenge""." The computer will give you the answer and you will lose.

  7. If the computer doesn't know the answer, he will say ""Challenge""" Then two things can happen:

1) You know the right answer and the moderator says it is correct and you win.


2) You don't know the right answer and you type in gibberish and the moderator marks it as wrong and you lose

  1. Whenever you think the computer has typed in the last letter of a place, press enter.

I'm looking for comments about the following points:

  1. coding style
  2. performance
  3. Readability of code
  • 1
    \$\begingroup\$ Welcome to Code Review. Can you include your code also? It is expected for reviews here. codereview.stackexchange.com/help/how-to-ask \$\endgroup\$ – chicks Jul 10 '18 at 17:32
  • \$\begingroup\$ @chicks The code is big so I included a link for it \$\endgroup\$ – Agile_Eagle Jul 10 '18 at 17:33
  • \$\begingroup\$ Welcome to Code Review! Unfortunately your question is off-topic as of now, as the code to be reviewed must be present in the question. Please add the code you want reviewed in your question. Thanks! \$\endgroup\$ – Malachi Jul 10 '18 at 18:26
  • \$\begingroup\$ @Malachi the formatting of the code gets disturbed if I add it in the question \$\endgroup\$ – Agile_Eagle Jul 10 '18 at 18:27
  • \$\begingroup\$ @Agile_Eagle: We can attempt to fix it in that case. \$\endgroup\$ – Jamal Aug 13 '18 at 23:30

By far the most important thing you can change is splitting your code up into smaller functions. For example, every time you print with random colors, that could be a function:

def print_colored(str, n=1):
    for i, x in enumerate(str):
        if i % n == 0:
                print(x, end='')
                os.system("color " + str(randint(1, 8)))
                print(x, end='')

Things like your main game loop can also be made a function to hide variables and make your code easier to read.

Seperation of concerns is very important in programming. In it's current state, I cant tell what is going on with out reading and understanding the entire program at once.

| improve this answer | |
  • \$\begingroup\$ I will keep that in mind \$\endgroup\$ – Agile_Eagle Jul 10 '18 at 16:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.