Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

split array of arrays into single elements (gambling game project)

I am trying to generate a list of all possible outcomes of a football/soccer match that I will then pass into another function. However, my program creates a list of 10 lists (each containing two elements) instead of one long list. Thus, it will not loop through in the coming function.

I am unable to use .split() because there was nothing I could use as a proper splitting character.

Does anyone know how I can either break up "test_scores" or how to generate a single, 100 object list, from the beginning?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you so much.

import numpy as np

team1= np.array(list(range(10)))
team2=np.array(list(range(10)))

#arrays for all possible game outcomes in range ten between team 1 and 2
scores=[[[x,y] for x in team1] for y in team2]
test_scores = scores
print(test_scores)

>Solution :

So close! Just delete two characters:

scores=[[x,y] for x in team1 for y in team2]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading