TypeError unsupported operand type s for list and list

+1 vote

This is my part of code, why it shows: TypeError: unsupported operand type(s) for /: 'list' and 'list'
<Figure size 576x288 with 0 Axes>

plt.figure(figsize=(8, 4))
plt.scatter(p_vol, p_ret,c=p_ret / p_vol, marker='o')

plt.scatter(t_vol, trets,c=trets / t_vol, marker='x')

plt.plot(statistics(opts['x'])[1], statistics(opts['x'])[0],'r*', markersize=15.0)
# portfolio with highest Sharpe ratio
plt.plot(statistics(optv['x'])[1], statistics(optv['x'])[0],'y*', markersize=15.0)
# minimum variance portfolio
plt.grid(True)
plt.xlabel('expected volatility')
plt.ylabel('expected return')
plt.colorbar(label='Sharpe ratio')
May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 2,935 views

Hey, @Noman,

Just check that you have defined plt in your code or not, probably you are getting this error because of that.

Its shows this error everything is fine 

TypeError                                 Traceback (most recent call last)
<ipython-input-334-7d2a34ebfdb9> in <module>
      1 plt.figure(figsize=(8, 4))
----> 2 plt.scatter(p_vol, p_ret,c=p_ret / p_vol, marker='o')
      3                 # random portfolio composition
      4 plt.scatter(t_vol, trets,c=trets / t_vol, marker='x')
      5             # efficient frontier

TypeError: unsupported operand type(s) for /: 'list' and 'list'

<Figure size 576x288 with 0 Axes>

Hey, @Noman,

It might be because you are running the loops for the complete length of data.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
1 answer

TypeError: unsupported operand type(s) for -: 'list' and 'int'

Hey, @William For me the code is working ...READ MORE

answered Mar 11, 2020 in Python by Roshni
• 10,480 points
3,519 views
0 votes
0 answers

How can I solve it? TypeError: unsupported operand type(s) for /: 'float' and 'list'

I am trying to calculate numerical integration ...READ MORE

Nov 17, 2020 in Python by asimsek
• 120 points
13,829 views
0 votes
3 answers

TypeError: unsupported operand type(s) for -: 'str' and 'str'

& is "bitwise and" operand in Python, you ...READ MORE

answered Dec 11, 2020 in Python by Rajiv
• 8,870 points
80,678 views
0 votes
0 answers

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Hi guys i have below code . ...READ MORE

Oct 30, 2019 in Python by sumanth
• 190 points
12,021 views
0 votes
0 answers

TypeError: unsupported operand type(s) for *: 'CommentedMap' and 'CommentedMap' Hatam bu nasıl çözebilirim ?

from ruamel import yaml from scipy import spatial import ...READ MORE

Sep 29, 2020 in Python by anonymous
• 120 points

edited Sep 29, 2020 by Gitika 823 views
0 votes
1 answer

Test Failed: unsupported operand type(s) for -: 'tuple' and 'list'

Hi, @There, Check what are you passing.. the ...READ MORE

answered Oct 5, 2020 in Python by Gitika
• 65,770 points
2,910 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,123 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