#returns the multaples of the num, and the repeating sequence made from the num. def seq(num): try: int(num) except ValueError: return num, "not integer value" l = [] for x in range(21): l.append(x*num) s = l[0:11] c = False while not c: c = True for i, n in enumerate(l): l[i] = n%10 l[i-1] += (n-(n%10))/10 for i, n in enumerate(l): l[i] = int(n) if n-(n%10) != 0: c = False return s, l[0:9] #in use: for x in range(10): y, z = seq(x+1) print "multaples:", y print "sequence:", z, "...repeating" print
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question