Python Homework score of each name pair
<p>I've got an exercise to do and I don't know why, it is not working...</p>

<p>I really hope someone could help me</p>

<p>Thank you in advance</p>

<blockquote>
  <p>Calculate and display the score of each name pair (using the lists
  list_2D = [âJohnâ,âKateâ,âOliâ]and[âGreenâ, âFletcherâ,âNelsonâ]). The
  score of a name combination is calculated by taking the length of the
  concatenated (merged) string storing the first and last names and
  adding the number of vowels in it. For example, Oli Green has length 9
  (counting space between first and last name) + 4 for the four vowels,
  resulting in a total score of 13.</p>
</blockquote>

<p>I have changed some aspects because I am not going to do your homework for you, but I understand just starting out on Stack and learning to program. It isn't easy so here's some explanation.</p>

<p>So what you will want to do is loop through all of the possible combinations of the first and last names.</p>

<p>I would do a nested for loop:</p>

<p>here is the first part:</p>

<pre><code>array1 = ['John', 'Kate', 'Oli']
array2 = ['Green', 'Fletcher' ,'Nelson']

for i in range(0,3):
    for k in range(0,3):
        val = array1[i] + " " + array2[k]
        print(val)
</code></pre>

<p>What you are doing is you are keeping <code>i</code> at zero, and then looping through everything in the second list. This way you can get every permutation of your list. To find the length you can do a for counting loop starting at position 0 or you can use the <code>.len()</code> function. To find the vowels you will need to look through each string you create and check to see if they match <code>[a, e, i, o, u]</code>. You can do something like </p>

<p><code>if (val[k] == vowelList[j]):
       score += score</code>      </p>

<p>That is how I would do it, but I am not as experienced as other people here.</p>

<p>Welcome to Stack! It is scary and a lot of people can be off putting and rude, just make sure to check other questions before you post and show some of your own work (what you have tried/attempted.)</p>

python python-2.7 python-3.x cloud9-ide cloud9