Overcoming TypeError: can't multiply sequence by non-int of type 'list'

24 Views Asked by At

This is only part of my code. I am trying to run this code to generate a function, but am receiving the following error when running line 3 of depicted code: TypeError: can't multiply sequence by non-int of type 'list'

for j in range(1,100):
    c[j]=j/100
    s[j]= T - [8.314*[[j/100]*[np.log(j/100)]]]

Assume T has been initialized before these three lines. s and c are not initialized outside of the for loop. Is there anyway that I can get this function to be generated properly as numeric values?

1

There are 1 best solutions below

1
meshkati On

You're trying to multiply a list by a list, which is causing the TypeError.

Try this:

import numpy as np

# Dunno what T is

c = [0] * 100
s = [0] * 100

for j in range(1, 100):
    c[j] = j / 100
    s[j] = T - 8.314 * (j / 100) * np.log(j / 100)