Python3 Generate string from number range

326
December 01, 2017, at 09:24 AM

I am relatively new to python3 and am trying to make a program that continuously adds new digits to a number The number is a number that adds 1 number to the previous number but adds it on as a string

For example the first few digits of the number would be 123456789101112131415161718...

I am wondering if there is an easy way to program this in python3 so that it continues infinitely creating this number.

Answer 1

All of the answers so far are very memory intensive, or quite finite.

I would consider the itertools.count generator and printing the results immediately. This will use very little memory, and is by far the most 'infinite' of the solutions posted so far.

from itertools import count
for c in count():
    print(c, end="")
Answer 2
k = ""
for i in range(0, 100):
    k = k + ''.join(str(i))
print(k)

will create till from 0 to 100 like so

0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899

Rent Charter Buses Company
READ ALSO
Get the subset with maximum diverse without compute all distance

Get the subset with maximum diverse without compute all distance

I read slide about top-k algorithms which are Fagin Algorithm (FA), Threshold Algorithm (TA) and No random access algorithm (NRA)Those algorithms are good because we do not need to see all values, we just need to set a threshold or compute lower bound and upper bound

224
Python unittest case

Python unittest case

I got below error msg when I run my unittest case, and why the 2nd case(test_createproject) cannot be run?

257
Connecting to an SFTP server for the first time with pysftp

Connecting to an SFTP server for the first time with pysftp

I'm in kind of a bizarre situation where I need to connect to an SFTP server for the first time but I can't seem to find a way to get access to the known host entry for the serverI can connect fine if I say:

325
Python - Changing dataframe order values

Python - Changing dataframe order values

I'm trying to change the dataframe printout so that it starts numbering the first dataframe entry at 40 instead of 0

350