python error TypeError: not all arguments converted during string formatting
<p>Been starring at this too long and I think I missed something dumb..
Writing a script to write information to a file. All the variables are strings being passed in from another function to write a file.</p>

<p>Here's my code: </p>

<pre><code> 53 def makeMainTF():
 54         NameTag,mcGroupTag,mcIPTag = makeNameMCTag()
 55         yourName = getAccessSecretName()
 56         instanceType ="t2.micro"
 57         with open ("vlslabMain.tf","w") as text_file:
 58                 text_file.writelines(['provider \"aws\" {\n',
 59                                       '  ',
 60                                         'access_key = \"${var.access_key}\"\n',
 61                                       '  ',
 62                                         'secret_key = \"${var.secret_key}\"\n',
 63                                       '  ',
 64                                         'region     = \"${var.access_key}\"\n',
 65                                       '}\n\n\n',
 66                                       'resource \"aws_instance\" \"example\" {\n',
 67                                         '  ',
 68                                       'ami = \"${lookup(var.amis, var.region)}\"\n',
 69                                         '  ',
 70                                         'instance_type = \"%s\" \n}' % instanceType,
 71                                         '\n\n\n\n',
 72                                         'tags {\n',
 73                                         '   ',
 74                                         'Name = \"%s\"\n' % NameTag,
 75                                         '   ',
 76                                         'Multicast = \"%s,%s\"' % (mcGroupTag,mcIPTag),
 77                                         '   ',
 78                                         'Owner = \"%s\"' % yourName,
 79                                         '\n}'])
</code></pre>

<p>Not sure why I'm getting this error :</p>

<pre><code>Enter Access Key: asd
Enter Secret Key: asd
Enter your name: asd
Access Key: asd
Secret Key: asd
Your full name is: asd
Traceback (most recent call last):
  File "terraTFgen.py", line 86, in &lt;module&gt;
    makeMainTF()
  File "terraTFgen.py", line 78, in makeMainTF
    'Owner = \"%s\"' % yourName,
TypeError: not all arguments converted during string formatting
</code></pre>

<p>Maybe I've been starring at it too long but I dont see the syntax mistake.</p>

<p>It actually wrote out </p>

<pre><code>Enter Access Key: asd
Enter Secret Key: asd
Enter your name: asd
Access Key: asd
Secret Key: asd
Your full name is: asd
</code></pre>

<p>But the error is causing the script not to write to the actual file.</p>

<p>Thanks for the help!
****edit***</p>

<p>This is the function I used to get the  yourName variable</p>

<pre><code> 3 def getAccessSecretName():
  4         access_key = raw_input("Enter Access Key: ")
  5         secret_key = raw_input("Enter Secret Key: ")
  6         yourName = raw_input("Enter your name: ")
  7         print "Access Key: %s" % access_key
  8         print "Secret Key: %s" % secret_key
  9         print "Your full name is: %s" % yourName
 10         return access_key, secret_key, yourName
</code></pre>

<p>Replace line 78 with the following and try - </p>

<pre><code>'Owner = \"%s\"' % " ".join(yourName),
</code></pre>

<p>Effectively, yourname seems to be a tuple.<br>
The above code will convert it to a string value.</p>

<p>EDIT :- (Answer to the OP's last comment)    </p>

<p>Look at line 10 of <code>getAccessSecretName()</code> function - </p>

<pre><code>return access_key, secret_key, yourName
</code></pre>

<p>It returns a <strong><em>tuple</em></strong> of <em>access_key, secret_key, and yourName</em>.</p>

<p>So if you want only <code>yourName</code> to be written to your file, </p>

<p>(Option 1)</p>

<p>Replace line 55 in function  <code>getAccessSecretName()</code> with</p>

<pre><code>access_key, secret_key, yourName = getAccessSecretName()
</code></pre>

<p>This way you the three values are unpacked to different variables,</p>

<p>and replace line 78 with the following  -</p>

<pre><code>'Owner = \"%s\"' % yourName
</code></pre>

<p>EDIT 2  (Option II)</p>

<p>If you are only interested in <code>yourName</code> variable you can also do 
something like </p>

<pre><code>yourName = getAccessSecretName()[2]
</code></pre>

<p>Replace line 55 with the above line. Here you will be copying the value of the tuple at a specific position to the variable <code>yourName</code> and ignoring other values.</p>

python