Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple quotation marks to format long strings. Here are Here are some other methods to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple quotation marks to format long strings. Here are some other methods to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple quotation marks to format long strings. Here are some other methods to format long strings.

added 589 characters in body
Source Link
N3buchadnezzar
  • 5.8k
  • 25
  • 40
  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple parenthesisquotation marks to format long strings. Here are some other methods to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple parenthesis to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesome string formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings.

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters. This is a good rule of thumb. You can use triple quotation marks to format long strings. Here are some other methods to format long strings.

added 589 characters in body
Source Link
N3buchadnezzar
  • 5.8k
  • 25
  • 40
  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. The old string format for Python was '%s %s' % ('one', 'two') whileis the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with with the new one. Check here to learn more about Pythons awesomestring formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings .

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters . This is a good rule of thumb. You can use triple parenthesis to format long strings.

\${}{}\$

for blank in blanks:
 ans = ""
 while not ans:
 ans = input(blank.capitalize() + "> ")
 if not ans:
 print("Please don't leave anything blank. It kills the experience.")
 blank['ans'] = ans

\${}{}\$

  1. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  2. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the store. The key here is .lower().

  3. Your commenting is good, however it could be improved by using doc strings

  4. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors.

  5. In PEP 8, it is recommended that the maximum linewidth is 79 characters . This is a good rule of thumb. You can use triple parenthesis to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. The old string format for Python was '%s %s' % ('one', 'two') while the '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesomestring formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

\${}{}\$

for blank in blanks:
 ans = ""
 while not ans:
 ans = input(blank.capitalize() + "> ")
 if not ans:
 print("Please don't leave anything blank. It kills the experience.")
 blank['ans'] = ans

\${}{}\$

  1. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  2. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the store. The key here is .lower().

  3. Your commenting is good, however it could be improved by using doc strings

  4. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors.

  5. In PEP 8, it is recommended that the maximum linewidth is 79 characters . This is a good rule of thumb. You can use triple parenthesis to format long strings.

  1. The golden standard for style in python is PEP 8. It explains in excruciating detail how to structure your code. I whole heartily recommend skimming through it and follow it.

  2. Use the if __name__ == "__main__": module. It makes your code clearer and reusable.

  3. blanks does not have to be a list of dicts. It is clearer if it only holds the type

  4. '%s %s' % ('one', 'two') is the old string format while '{} {}'.format('one', 'two') is the new one. I recommend sticking with the new one. Check here to learn more about Pythons awesomestring formating options.

  5. if len(ans) == 0: is a unorthodox way to change if a string is empty. A more pythonic approach is if not ans.

  6. Do not use quit() a better approach is to make the ans into a while loop

     for blank in blanks:
     ans = ""
     while not ans:
     ans = input(blank.capitalize() + "> ")
     if not ans:
     print("Please don't leave anything blank. It kills the experience.")
     blank['ans'] = ans
    
  7. A bigger concern is that you update blank['ans'] = ans, but then immediately move the values into a list.

    fs = []
    # Get the answers from the blanks list
    for dictionary in blanks:
     fs.append(dictionary['ans'])
    

    Why not have the answers as a list from the start?

  8. You capitalize the words on input. However when asking if the user liked the story you do not lower the words. When i write Y it tells me I did not like the story. The key here is .lower().

    if feedback.lower() == "y":
     print("Thanks!")
    
  9. Your commenting is good, however it could be improved by using doc strings .

  10. A more severe concern with your code is that it is not modular. You have everything lumped into a single file. Really you should NEVER have that. Create a function named get_user_input which handles all the errors. Another code to ask the user to play again and so forth. A basic structure is something like the following

    import

    CONSTANTS

    def some_function():

    def another_function():

    def main() while True: some_function() play_again = input('do you want to play again? [y/n]: ') if play_again.lower() not in ['y', 'yes', 'ok']: break

    if name == 'main': main()

  11. In PEP 8, it is recommended that the maximum linewidth is 79 characters . This is a good rule of thumb. You can use triple parenthesis to format long strings.

added 24 characters in body
Source Link
N3buchadnezzar
  • 5.8k
  • 25
  • 40
Loading
added 299 characters in body
Source Link
N3buchadnezzar
  • 5.8k
  • 25
  • 40
Loading
Source Link
N3buchadnezzar
  • 5.8k
  • 25
  • 40
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /