- 1
Sequence numbering Python 3
If i wamt to output 1. 2. 3. But don't want to keep writing each number..os there a way to make it faster ?
13 ответов
+ 6
Amer ,
range can take 3 arguments:
range(<start number>, <end number ( not including )>, <step>)
see what this code is resulting:
for num in range(5, 11):
print(num)
'''
result is:
5
6
7
8
9
10
'''
+ 4
if u use a wild range of numbers
for n in [1,4,7,9,74]:
print(f"{n}. ")
+ 3
for n in range (x):
print(n)
----
This will print all integers from 0 to x.
+ 3
.... Simons solution but
print(f"{n}.")
+ 3
for n in range(5, 11):
if n != 7:
print(n)
+ 2
Amer ,
i don't know what language you are going to, but you ca do it with a loop. you may need to get an input to define the max number to output.
the numbers itself can be generated by a range or with a variable that will be incremented in each loop iteration.
the dot after the number can be added during print output.
happy coding and good success!
+ 2
Thanks guys it worked.
One more thing
Say i want to exclude 0..or make the range from 5 to 15 for example. How would it go.
+ 1
I'm learning python 3
Could you please assist me with an example ?
+ 1
Perfect.
Say i want to exclude 7 from that range you resulted.
So 5 6 8 9 10
Last question i swear 😆
0
Thanks alot guys
0
This one gave error
0
Works..thanks folks!