user26549: I am a beginner looking to write a simple program that takes an input (address) and prints the unspent amount in it.
I copied some code from chapter 4 of Mastering Bitcoin to generate a random keypair, and the last lines Andreas had in the code I copied were:
>     # Generate bitcoin address from public key
>       print "Bitcoin Address (b58check) is:", bitcoin.pubkey_to_address(public_key)
>     
>     # Generate compressed bitcoin address from compressed public key
>       print "Compressed Bitcoin Address (b58check) is:", \
>           bitcoin.pubkey_to_address(hex_compressed_public_key)

I added the following bit at the end that prints the UTXO. It is currently printing "[ ]" because there are no UTXOs because I'm generating a new address, but it at least works when I do this and prints something.
>     #Print the UTXO for the given address     
>     print bitcoin.unspent(bitcoin.pubkey_to_address(public_key))

However, when I type an address instead of the "(bitcoin.pubkey_to_address(public_key))", like so:
>     print bitcoin.unspent(16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED)

It gives me an error ("SyntaxError: invalid syntax) and points to the "D" at the end of the address. I really want to use this specific bit of code to enable me to enter an address and have the UTXOs returned. (Please note, I just found that address on blockchain.info by clicking addresses until one with unspent coins came up! Also I am a complete novice so please go easy on me!)
Thanks in advance

user26549: >     print bitcoin.unspent('16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED')

Sovled the issue.

26549: <p>I am a beginner looking to write a simple program that takes an input (address) and prints the unspent amount in it.</p>

<p>I copied some code from chapter 4 of Mastering Bitcoin to generate a random keypair, and the last lines Andreas had in the code I copied were:</p>

<pre><code>&gt;     # Generate bitcoin address from public key
&gt;       print "Bitcoin Address (b58check) is:", bitcoin.pubkey_to_address(public_key)
&gt;     
&gt;     # Generate compressed bitcoin address from compressed public key
&gt;       print "Compressed Bitcoin Address (b58check) is:", \
&gt;           bitcoin.pubkey_to_address(hex_compressed_public_key)
</code></pre>

<p>I added the following bit at the end that prints the UTXO. It is currently printing "[ ]" because there are no UTXOs because I'm generating a new address, but it at least works when I do this and prints something.</p>

<pre><code>&gt;     #Print the UTXO for the given address     
&gt;     print bitcoin.unspent(bitcoin.pubkey_to_address(public_key))
</code></pre>

<p>However, when I type an address instead of the "(bitcoin.pubkey_to_address(public_key))", like so:</p>

<pre><code>&gt;     print bitcoin.unspent(16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED)
</code></pre>

<p>It gives me an error ("SyntaxError: invalid syntax) and points to the "D" at the end of the address. I really want to use this specific bit of code to enable me to enter an address and have the UTXOs returned. (Please note, I just found that address on blockchain.info by clicking addresses until one with unspent coins came up! Also I am a complete novice so please go easy on me!)</p>

<p>Thanks in advance</p>
 26549: <pre><code>&gt;     print bitcoin.unspent('16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED')
</code></pre>

<p>Sovled the issue.</p>
