Printing a score sheet for baseball batters I've been learning Python 2.7 for about a week now and have written a quick program to ask for names of batters and printing a score sheet. I have then added the names to a list which I will use more in other future functions.

I have a few questions:


I feel like there is too much repetition in my code, such as the prompting for each batter and all the printing. I am trying to figure out how I could use a loop to do these for me. Since I know I need 11 batters a for loop would be best but I need to make a new variable each time, how can I do this?
I have been reading around about the use of global. I can't seem to get a definite answer but is this the correct use if I want to use a variable from one function in multiple others?




def Input_Players():

    global First, Second, Third, Fourth, Fith, Sixth, Seventh, Eigth, Ninth, Tenth, Eleventh

    First = [raw_input("Name of 1st Batsman &gt; ")]
    Second = [raw_input("Name of 2nd Batsman &gt; ")] 
    Third = [raw_input("Name of 3rd Batsman &gt; ")] 
    Fourth = [raw_input("Name of 4th Batsman &gt; ")] 
    Fith = [raw_input("Name of 5th Batsman &gt; ")]
    Sixth = [raw_input("Name of 6th Batsman &gt; ")] 
    Seventh = [raw_input("Name of 7th Batsman &gt; ")] 
    Eigth = [raw_input("Name of 8th Batsman &gt; ")] 
    Ninth = [raw_input("Name of 9th Batsman &gt; ")] 
    Tenth = [raw_input("Name of 10th Batsman &gt; ")] 
    Eleventh = [raw_input("Name of 11th Batsman &gt; ")] 

def Print_Score_Sheet():
    total_chars = 56

    Batsman = First + Second + Third + Fourth + Fith + Sixth + Seventh + Eigth + Ninth + Tenth + Eleventh



    print "1." + Batsman[0] + "." * (total_chars - len(Batsman[0]) + 2)
    print "2." + Batsman[1] + "." * (total_chars - len(Batsman[1]) + 2)
    print "3." + Batsman[2] + "." * (total_chars - len(Batsman[2]) + 2)
    print "4." + Batsman[3] + "." * (total_chars - len(Batsman[3]) + 2)
    print "5." + Batsman[4] + "." * (total_chars - len(Batsman[4]) + 2)
    print "6." + Batsman[5] + "." * (total_chars - len(Batsman[5]) + 2)
    print "7." + Batsman[6] + "." * (total_chars - len(Batsman[6]) + 2)
    print "8." + Batsman[7] + "." * (total_chars - len(Batsman[7]) + 2)
    print "9." + Batsman[8] + "." * (total_chars - len(Batsman[8]) + 2)
    print "10." + Batsman[9] + "." * (total_chars - len(Batsman[9]) + 1)
    print "11." + Batsman[10] + "." * (total_chars - len(Batsman[10]) + 1)

Input_Players()
Print_Score_Sheet()
I would structure the code like this:

def input_players(total=11):
  players = []

  for index in range(total):
    player = raw_input('Name of Batsman {} &gt; '.format(index + 1))
    players.append(player)

  return players

def print_score_sheet(batsmen, total_chars=56):
  for index, batsman in enumerate(batsmen, 1):
    print '{}. {} '.format(index, batsman).ljust(total_chars, fillchar='.')

if __name__ == '__main__':
  players = input_players(11)
  print_score_sheet(players)


Some tips:


If you use a set of variables like Player1, Player2, PlayerN, you should be using a list to store them.
Your functions should do what they say. input_players() should return a list of players, nothing more, nothing less.
Get into the habit of including the if __name__ == '__main__': block. The stuff inside of the block is executed only if you run the Python script directly, which is good if you have multiple modules.