Sorry for the simple question.
def date():
for num in range (0,100):
num+=1
print(num)
What should I do if I want to put this result (all results from 1 to 100) in the array?
python
How about this
def date():
result=[]# A list of results is provided
for num in range (0,100):
num+=1
print(num)
result.append(num)# Add Results
return result# Returns a list of results
If you don't have print()
, you can write like this using the list composition.
def date():
return [ x+1 for x in range (0,100) ]
© 2024 OneMinuteCode. All rights reserved.