2

I'm new in Python, and didn't find previous questions that describe the issue I'm asking for. Thank you.

1) My first question is, why the type that I get here is not a real List ? (the [ ] in the output, looks like a list but it's not, as you can see in the line below).

2) How can I convert the values in this 'dict_values' to integers inside a List (to make some calculations later) ?

print(list(node_list[j].neighbors.values()))
print(type(node_list[j].neighbors.values()))

The output is:

[10, 20, 20, 5, 10]
<class 'dict_values'>
Eli
  • 31
  • 1
  • 2
  • It looks like you've already figured out how to convert it to a list of integers? – Aran-Fey Jul 28 '18 at 11:35
  • your'e getting a list because you are converting the input to a list, can you show the rest of the code? – Maor Veitsman Jul 28 '18 at 11:36
  • No, I did not figured out yet. How can I add here the rest of the code just in the comment in a readble way ? – Eli Jul 28 '18 at 11:45
  • `[10, 20, 20, 5, 10]` <- That's a list of integers. If that's not the output you want, I don't understand your question. – Aran-Fey Jul 28 '18 at 11:47
  • Well, it works now. I just ignored the type and started with the claculations which haven't work before. Anyway, the type which shows up is still 'dict_values' Thank you. – Eli Jul 28 '18 at 12:05

0 Answers0