By YashPatel
The Series Is - 1 2 3 4 5 6 7 8 9 10 …‘N’
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This should do the trick for you, let me know if I can help explain it further!
counter = 0 # Last number printed
terms = 0 # How many terms were printed last
target = 10 # Change this! How many terms we want to reach
while terms < target:
terms += 1
items = []
for i in range(terms):
counter += 1
items.append(counter)
print(items) # Output the line, do what you want to make it prettier here
Output[1]
[2, 3]
[4, 5, 6]
[7, 8, 9, 10]
[11, 12, 13, 14, 15]
[16, 17, 18, 19, 20, 21]
[22, 23, 24, 25, 26, 27, 28]
[29, 30, 31, 32, 33, 34, 35, 36]
[37, 38, 39, 40, 41, 42, 43, 44, 45]
[46, 47, 48, 49, 50, 51, 52, 53, 54, 55]
Hope that helps! - Matt.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.