def load_matrix():
matrix = sys.stdin.read()
matrix = matrix.strip().split('\n')
matrix = [row.split(' ') for row in matrix]
for m in matrix:
matrix=[int(l) for l in m]
print("\n Data Loaded Sucessfully")
print("\n")
var=pd.DataFrame(matrix)
return var
Look at this piece of code. I am trying to take a matrix directly as the input for the program, but the read function takes the input as a list of strings. To convert it into a int object for performing math functions, i have used the code above. running fine with online compilers but VS Code keeps throwing an error saying:
ValueError: invalid literal for int() with base 10: '4\x1a' (when given the input as:- This )
From what I have researched, this happens when the value passed cannot be converted into an integer.
When I run a similar code in Jupyter notebook it runs smoothly. Your Help will be appreciated.