I only recently started taking classes in CIS and thus am unfamiliar with python to say the least. I was hoping I could get a few suggestions on a program I recently started. I've written a 5th edition D&D initiative tracker, the trouble I'm having is how to break it into modules from here. I am just now learning list(arrays) in python and am at a loss particularly arguments and parameters in regards to dealing with lists. Thanks in advance!
Code to follow
from random import randint
# Entering player names at the beginning of the session
def main():
print("Enter PC names, separated by commas (David,Matt,Peter,etc.):")
pcs = input().split(',')
# Loops every time a new battle has started
while True:
# Setting up enemies
num_foes = int(input("How many foes? "))
foes = []
foes = ["Enemy " + str(n+1) for n in range(num_foes)]
# Setting up enemy initiative modifiers
foe_init_mods = []
for foe in foes:
foe_init_mods.append(int(input(foe + "'s initiative modifier? ")))
# Setting up player initiative modifiers
pcs_init_mods = []
for pc in pcs:
pcs_init_mods.append(int(input(pc + "'s initiative modifier? ")))
# Setting up initiatives
chars = []
for i, pc in enumerate(pcs):
chars.append([randint(1, 20) + pcs_init_mods[i], pc])
for i, foe in enumerate(foes):
chars.append([randint(1, 20) + foe_init_mods[i], foe])
# Ordering characters by initiative
chars.sort()
# Displaying characters in order of initiative
print("\n--- Initiative List ---")
for i, char in enumerate(chars[::-1]):
print(str(i+1) + ". " + char[1] + " (" + str(char[0]) + ")")
# User decides if loop should terminate or not
break_loop = input("\nAnother battle? (Y/N) ") == "N"
if break_loop:
print("Bye!")
break
else:
print("Onwards!")
main()