Ad
  • Custom User Avatar

    Good point :), nice.

  • Default User Avatar

    I absolutely agree. Thanks for the comment. Even better, I can use enumerate instead of index:

    tobase64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
    frombase64 = {v: i for i, v in enumerate(tobase64)}
    
  • Custom User Avatar

    I didn't go through your entire solution, but glancing over your code, you could've made the tobase64 a string rather than a dictionary:

    tobase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
    frombase64 = {x: tobase64.index(x) for x in tobase64}
    

    I'm sure I am not the only one that dislikes lines over 80 characters long, let alone a dictionary 450 characters long on a single line.