5 ms·
Does this fit the criteria for python: print str(range(1,1001)).strip('[]').replace(', ','\n') Edit: added missing [ as pointed out below
by rararational 16y ago
Does this fit the criteria for python:
print str(range(1,1001)).strip('[]').replace(', ','\n')
Edit: added missing [ as pointed out below
- kroo 16y agono! For one thing, it still prints out an opening '[' before 1. Second of all, relying on the structure of the string representation of an array is just silly. Perhaps: print "\n".join(map(str, range(1,1001))) or print "\n".join(str(i) for i in range(1,1001))
- rararational 16y agoHeh, I forgot about join but that for is still a loop right? :) Or else you could just: for i in range(1,1000): print i Plus relying on the string representation of a list isn't silly it as it doesn't change. I just didn't know if range would meet the criteria or not.