App for a tabletop RP that generates hits and misses for weapons I'm looking for tips on cleaning this up. I think it's legible, but it sure ain't pretty. In particular, I'd love to clean up the hitCheck function. I've dealt with switches before in other languages, so I was kind of stuck on trying simulating that. getReady looks messy to me, but I'm not sure how I'd go about tidying that up either.

import random
import time

def hitCheck(rng, acc):
    hitTotal = acc + rng
    if hitTotal &gt; 190:
        print("CRIT! HEADSHOT!")
        return 5
    if 160 &lt; hitTotal &lt; 191:
        print("Lethal!")
        return 4
    if 120 &lt; hitTotal &lt; 161:
        print("Severe!")
        return 2
    if 80 &lt; hitTotal &lt; 121:
        print("Ouch!")
        return 1
    if 40 &lt; hitTotal &lt; 81:
        print("Grazed!")
        return 0.5
    if 0 &lt; hitTotal &lt; 41:
        print("Miss!")
        return 0

def firing(begin):
    print("BANG!")
    #end &amp; start variables are used to tell how fast the user is pressing the key.
    #The faster they go, the more inaccurate their shots.
    end = time.time()
    accuracy = int((end - begin) * 60)
    if accuracy &gt; 100:
        accuracy = 100
    #print("Accuracy: ", accuracy)
    #Not sure if this 'luck' generator is mathematically different
    #from just using 'int((random.random() * 100))'.
    luck1 = int((random.random() * 50))
    luck2 = int((random.random() * 50))
    luck = luck1 + luck2
    #print("Luck: ", luck)
    return hitCheck(luck, accuracy)

#Here's the main part of the app.
def getReady():
    running = False
    while not running:
        i = 0
        downed = 0
        total = 0
        while True:
            print("\n")
            total = input('Max attempts: ')
            print("\n")
            if total == '' or int(total) &lt; 0:
                print("Value must be higher than 0!")
            else:
                total = int(total)
                break

        print("Fire away!")
        while i &lt; total:
            #Other half to figuring out the accuracy.
            start = time.time()
            input()
            downed += firing(start)
            i += 1
            print(total - i, " shots left.")
            time.sleep(0.1)

        #Print the results!
        print("\n")
        print("Injuries:", int(downed))
        print("You felled", round(downed / 5), "foes!")
        print("\n")

        #Shall we continue?
        while True:
            running = input("More? yes / no: ")
            if running in ('no', 'n'):
                running = True
                break
            elif running in ('yes', 'y'):
                running = False
                break
            else:
                continue

getReady()
The way you normally emulate switches in Python is with a dictionary. That's a bit of a funny solution when you have to evaluate all these conditions though. If they were regular values then you could mathematically determine them and save lines that way, but since you have the odd variations those changes would only obfuscate your code for the sake of a cleverer seeming solution. I would suggest you gather the printed values into a result at least. You could access them with a value key and return that value the same way.

hit_strings = {
                5: "CRIT! HEADSHOT!"
                3: "Lethal!",
                2: "Severe!",
                1: "Ouch!",
                0.5: "Grazed!",
                0: "Miss!",
              }

def hitCheck(rng, acc):
    hitTotal = acc + rng
    if hitTotal &gt; 190:
        result = 5
    if 160 &lt; hitTotal &lt; 191:
        result = 4
    if 120 &lt; hitTotal &lt; 161:
        result = 2
    if 80 &lt; hitTotal &lt; 121:
        result = 1
    if 40 &lt; hitTotal &lt; 81:
        result = 0.5
    if 0 &lt; hitTotal &lt; 41:
        result = 0

    print (hit_strings[result])
    return result


It's still long, but this does make it more modular and easier to expand with more values.

The luck generator isn't particular different no, just have one call. You should also remove your defunct comments that you used as print tests.

Your big problem in getReady is that you try to cram everything into one function. You could separate them out easily with functions like get_attempts

def get_attempts():
    while True:
        print("\n")
        total = input('Max attempts: ')
        print("\n")
        if total == '' or int(total) &lt; 0:
            print("Value must be higher than 0!")
        else:
            total = int(total)
            return total

#Here's the main part of the app.
def getReady():
    running = False
    while not running:
        i = downed = total = 0
        total = get_attempts()


Though going back to get_attempts, you should just put newline characters in your input string instead of on separate lines. Also it's better to validate that input is actually a number. The most Pythonic way to do this is to attempt to turn it into an integer and catch it if that's not possible.

def get_attempts():
    while True:
        total = input('\n\nMax attempts:\n\n')
        try:
            total = int(total)
        except ValueError:
            print("Value must be a number!")


Then you can test if it's greater than 0 and print the other message if it's not.

        if total &gt; 0:
            return total
        print("Value must be higher than 0!")


Splitting up your functions like this will make your code much neater and easier to change.