Python for cubing programs?

I shouldn't have looked... now my hate for unpythonic Python kicked in :). I'll leave it at this bit, though.

Code:
def createTable():
    letters = "ABCDEFGHIJKLMNOPQRSTUVWX"
    letterList = [[first + second]
                  for first in letters for second in letters
                  if first != second]
    writeFile(letterList)
    return letterList


def writeFile(letterList):
    with open("letterList.txt", "w") as file:
        for line in letterList:
            print(", ".join(line), file=file)
 
Last edited:
I shouldn't have looked... now my hate for unpythonic Python kicked in. I'll leave it at this bit, though.

Code:
def createTable():
    letters = "ABCDEFGHIJKLMNOPQRSTUVWX"
    letterList = [[first + second]
                  for first in letters for second in letters
                  if first != second]
    writeFile(letterList)
    return letterList


def writeFile(letterList):
    with open("letterList.txt", "w") as file:
        for line in letterList:
            print(", ".join(line), file=file)

Thanks for the help. I'm not a CS major, so this is purely just a hobby that I'm learning on the fly.

Most of the stuff I've done is javascript, but I do enjoy Python.
 
Back
Top