Directory size checker So I semi-wrote directory size checker by copying some parts from Stackoverflow.
It works as follows:

Select a directory you want to check the size of subdirectories inside.
It goes scans all the directories inside the chosen directory. If there are also just files, that's not a problem the recursive function can deal with that as well.
It goes through every subdirectory and checks for the file size. If there's a permission problem, it returns -1 (this way we can easily tell which directories caused acces issues).
The directory name and it's &quot;mass&quot; gets stored in a dictionary.
The whole dictionary gets sorted.
Items that are +1GB get the &quot;GB&quot; tag, while the ones between 0 and 1 get the &quot;MB&quot; tag, just for better precision.
(I like to change between directories faster, so I added an option to give &quot;r&quot; as an input to scan for a second time. Closing the script and reopening it takes time imo)

Now I can see which folder is the biggest and which ones are empty, I don't know why but in Windows I need to go 1:1 and check each folder size individually, which I dislike a lot. This way I can check folders that contain hundreds of gigabytes in seconds.
I would like to know what I could have done better or what was obnoxious.
import os
from tkinter import *
from tkinter.filedialog import askdirectory


def Main():
    Tk().withdraw()  # use to hide tkinter window
    Dir = askdirectory(title=&quot;Select Folder&quot;)  # shows dialog box and return the path

    print(&quot;LOADING...&quot;)  # Sometimes it takes long to output results, this just indicates that the program is working and not broken
    sort_dict = Sorter(Dir)  # Give the directory as an input

    print(&quot;\n-SORTED-\n&quot;)
    for i in sort_dict:
        if i[1] &gt; 1:  # continues using gigabytes
            fixed_float = float(&quot;{:.3f}&quot;.format(i[1]))
            data_type = &quot;GB:   &quot;
        elif i[1] &lt; 0:  # no acces
            print(f&quot;NO ACCES : {i[0]}&quot;)
            continue
        else:  # convert to megabytes
            mega_float = i[1] * 1024
            fixed_float = float(&quot;{:.3f}&quot;.format(mega_float))
            data_type = &quot;MB:   &quot;

        dflt_white_space = 8
        white_space = &quot; &quot; * (dflt_white_space - len(str(fixed_float)))
        print(f&quot;{fixed_float}  {white_space + data_type + i[0]}&quot;)

    if input(&quot;\nPress 'r' to retry, press anything else to exit\n&quot;) == &quot;r&quot;:
        Main()


def get_dir_size(Dir):  # Returns the `directory` size in bytes.
    total = 0
    try:
        for entry in os.scandir(Dir):  # print(&quot;[+] Getting the size of&quot;, directory)
            if entry.is_file():  # if it's a file, use stat() function
                total += entry.stat().st_size
            elif entry.is_dir():  # if it's a directory, recursively call this function
                total += get_dir_size(entry.path)
    except NotADirectoryError:  # if `directory` isn't a directory, get the file size
        return os.path.getsize(Dir)
    except PermissionError:  # if for whatever reason we can't open the folder, return -1
        return -1  # returns a negative size that will be visible (to use conditions) after the conversion
    return total


def get_subdirs(Dir):
    dir_array = []
    for x in os.listdir(Dir):
        dir_array.append(x)
    return dir_array


def Sorter(Dir):

    Dict = {}
    dir_array = get_subdirs(Dir)

    for x in range(len(dir_array)):
        file_size = float(get_dir_size(Dir + &quot;\\&quot; + dir_array[x])) / 1073741824  # Converts the bytes to GB

        Dict[dir_array[x]] = file_size

    sort_dict = sorted(Dict.items(), key=lambda x: x[1], reverse=True)
    return sort_dict


if __name__ == &quot;__main__&quot;:
    Main()
Function equal to built-in
def get_subdirs(Dir):
    dir_array = []
    for x in os.listdir(Dir):
        dir_array.append(x)
    return dir_array

This is exactly the same as os.listdir, so just use it instead of the whole function.
Iterate simpler
for x in range(len(dir_array)):
    file_size = float(get_dir_size(Dir + &quot;\\&quot; + dir_array[x])) / 1073741824  # Converts the bytes to GB

    Dict[dir_array[x]] = file_size

Can become:
for dir in dir_array:
    file_size = float(get_dir_size(Dir + &quot;\\&quot; + dir)) / 1073741824  # Converts the bytes to GB

    Dict[dir] = file_size

Constants at the start
Putting constants at the start of the code is better than putting them inside, so at the start:
BYTES_IN_GIGABYTE = 1073741824  

User message
Your code works for files so:
Dir = askdirectory(title=&quot;Select Folder&quot;)

becomes:
Dir = askdirectory(title=&quot;Select Folder or File:&quot;)

Fancy progressbar
A fancy way to signify that the program is working can be found here
-1 lost in code
You return -1 sometimes from get_dir_size but you never check for it.
One comment on the logic
for i in sort_dict:
    if i[1] &gt; 1:  # continues using gigabytes

I would rename i to dir and add a comment saying what i[1] is.
Cross platform compatibility
As suggested by @s.dallapalma avoid concatenating paths with the plus (+) sign, and use os.path.join or pathlib instead. Thus, the code can work on different OS.
I liked the attention to handling of exception and the new clean format strings.