0
print ('\n'.join([' '.join([i for i in range(1,j)]) for j in range(2,6)]))

Error

TypeError: sequence item 0: expected str instance, int found

I went through the link TypeError: sequence item 0: expected string, int found telling string.join connects elements inside list of strings, not ints.

I have updated my code like print ('\n'.join([' '.join([str(i) for i in range(1,j)]) for j in range(2,6)]))

I got the error TypeError: 'str' object is not callable

Following code is working fine

print ('\n'.join([' '.join(['i' for i in range(1,j)]) for j in range(2,6)]))

My Out

i
i i
i i i
i i i i
sre
  • 249
  • 1
  • 12

0 Answers0