print instance 0 id TypeError list object is not callable

0 votes
import boto3
ec2 = boto3.resource('ec2')
instance = ec2.create_instance(
    ImageId = 'ami-009d6802948d06e52',
    MinCount = 1,
    MaxCount = 1,
    InstanceType = 't2.micro')
print (instance[0].id)
Jan 18, 2019 in Python by Suraj
3,005 views
Do you have a default VPC?

1 answer to this question.

+1 vote

Hey @Suraj, For me its working fine. You need to verify that have you verified aws credentials or not?

This is the code I used for creating an Instance.

The instance Id was displayed as an output for ec2.create_instance

Here is the instance created.

Give me some more details on your error so that I can suggest you the solution.

answered Jan 18, 2019 by Priyaj
• 58,020 points

Thank you for the reply Priyaj.

This is what I receive when I tried to print the Instance Id. As I have few more instances, I tried it as print(instance(4).id) as well. This being the 5th yet the same response. Can you help further?

Hey @Suraj you just print the instance and the index. You don't use .id.

See this:-

The instance variable here is of type list. hence you have to use

print (instance[0].id)

To get the id of the required index instance.

Hope it helps.

Hey @Suraj,

The code that you are using is correct but when you are implementing it you are changing 

print (instance[0].id) 

to 

print (instance(0).id) 

This will work fine.

The code you have mentioned in the question and the code used in the screenshot is different. In the screenshot, you have used 

print (instance(0).id)

To address the index of a list, you have to use square brackets. Try this:

print (instance[0].id)
Thank you that helped me :)
Hello @Suraj, glad you found the solution.

Related Questions In Python

0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

answered Feb 9, 2019 in Python by Omkar
• 69,220 points
29,245 views
0 votes
0 answers

TypeError: 'list' object is not callable in python

I am a beginner in Python, created ...READ MORE

Feb 3, 2022 in Python by Nandini
• 5,480 points
1,073 views
0 votes
1 answer

i am normalizing the data set iris in python and get the error ::TypeError: 'numpy.float64' object is not callable

TRY THIS   #Nomalisation for i in names:     print(i)   ...READ MORE

answered Aug 20, 2019 in Python by Noel Deepak Palle
5,968 views
0 votes
3 answers

TypeError: 'module' object is not callable

Solve By Calling with Module Name Another solution to the TypeError: 'module' object ...READ MORE

answered Jan 4, 2021 in Python by Carlos
35,788 views
0 votes
0 answers

TypeError: 'int' object is not callable

This is the code : from __future__ import ...READ MORE

May 8, 2022 in Python by Kichu
• 19,040 points
672 views
0 votes
1 answer

Python error "'Series' object is not callable "

Try this: df['ln_returns'] = np.log(df['Close_mid']/df['Close_mid']) df['Close_mid'](1)) doesn't seem to ...READ MORE

answered Jul 22, 2019 in Python by Greg
17,492 views
0 votes
1 answer

TypeError: 'Element' object is not subscriptable

Hey Bharti, You can get some idea from ...READ MORE

answered Feb 18, 2020 in Python by Gitika
• 65,770 points
8,074 views
0 votes
1 answer

'tuple' object is not callable

Hey, @There, This kind of error happens once ...READ MORE

answered Aug 13, 2020 in Python by Rajiv
• 8,870 points
2,331 views
0 votes
1 answer

Python join: why is it string.join(list) instead of list.join(string)?

This is because join is a "string" ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 58,020 points
837 views
0 votes
1 answer

What are the differences between type() and is instance()?

Normally, in Python, you want your code ...READ MORE

answered Aug 6, 2018 in Python by Priyaj
• 58,020 points
669 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP