Skip to main content
added 117 characters in body
Source Link
MarianD
  • 1.9k
  • 1
  • 10
  • 20

What about following the PEP 8 -- Style Guide for Python Code?
This style guide is about consistency. Consistency with this style guide is important.

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

Note particularly surrounding your function definitions with 2 blank lines.

(You may check it online: PEP8 online - firstas your original code, thenas this one.)

What about following the PEP 8 -- Style Guide for Python Code?

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

Note particularly surrounding your function definitions with 2 blank lines.

(You may check it online: PEP8 online - first your original code, then this.)

What about following the PEP 8 -- Style Guide for Python Code?
This style guide is about consistency. Consistency with this style guide is important.

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

Note particularly surrounding your function definitions with 2 blank lines.

(You may check it online: PEP8 online - as your original code, as this one.)

added 117 characters in body
Source Link
MarianD
  • 1.9k
  • 1
  • 10
  • 20

What about following the PEP 8 -- Style Guide for Python Code?

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

Note particularly surrounding your function definitions with 2 blank lines.

(You may check it online: PEP8 online - first your original code, then this.)

What about following the PEP 8 -- Style Guide for Python Code?

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

(You may check it online: PEP8 online.)

What about following the PEP 8 -- Style Guide for Python Code?

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

Note particularly surrounding your function definitions with 2 blank lines.

(You may check it online: PEP8 online - first your original code, then this.)

Source Link
MarianD
  • 1.9k
  • 1
  • 10
  • 20

What about following the PEP 8 -- Style Guide for Python Code?

Your code will become

from tkinter.colorchooser import askcolor


def text_data(text):
    texti = []
    binary = []
    ordv = []
    hexadecimal = []
    octal = []
    i = 0
    while i < len(text):
        j = ord(text[i])
        k = bin(ord(text[i]))
        l = hex(ord(text[i]))
        m = oct(ord(text[i]))
        k = k[2:]
        l = l[2:]
        m = m[2:]
        print(text[i], " ", j, " ", k, "", l, "", m)
        binary.append(k)
        ordv.append(j)
        hexadecimal.append(l)
        texti.append(text[i])
        octal.append(m)
        i += 1
    print("\n")
    print(binary)
    print("\n")
    print(ordv)
    print("\n")
    print(hexadecimal)
    print("\n")
    print(octal)


def colorcode():
    return askcolor()[1]


print(colorcode())

(You may check it online: PEP8 online.)