8

Hey guys, need an opinion.
Please have a look at the picture and let me know if it's a good practice to code like that. The code still works and I still get the output.

Comments
  • 2
    a = int(input("..."))

    # diff = abs(17-a)
    # edit: i just saw you don't need the abs
    diff = 17 - a

    print("...", diff) # the arguments are joined by spaces. no need for the final space in the string

    if a > 17:
    double = a * 2
    print("...", double) # see above
  • 2
    @gitreflog and it could still be shorter since both variables are used only in one place
  • 2
    1) no need to declare c twice. It holds the same value, so just declare it outside the if-else conditions
    2) technically your code doesn't even need the else block, the only 'true' code running after the check, is to get th value of 'd'. So you should only use the "if" check.
  • 2
    @Charon92 Its not just you, I feel the same way
  • 0
    @Charon92 except for a <3
  • 3
    If your code contains duplication, you're doing it wrong.
  • 5
    Name your variables correctly!
    Name your variables correctly!
    Name your variables correctly!
    Name your variables correctly!
    😠
  • 0
    Reuse variables, saves energy
Add Comment