-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS2-ListOfDigits.py
More file actions
39 lines (28 loc) · 998 Bytes
/
S2-ListOfDigits.py
File metadata and controls
39 lines (28 loc) · 998 Bytes
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
"""
This program takes a number and returns a list of digits
Author: Aditya Nain
Date: 01/23/2019
"""
"""
********pseudocode*******
define function listOfDigits
listOfDigits takes a number as an argument
initialise an empty list
use for-loop to loop through all the digits
convert them to integer and add to the empty list one by one
print the list of digits to screen
"""
#function to get a list of digits in a number
def listOfDigits(number):
#initialising an empty list
listOfDigits = []
#looping through all the digits in number
for i in number:
#coverts digits to int and adds it to the empty list "listOfDigits"
listOfDigits.append(int(i))
#print list of digits to screen
return print(f"List of Digits : {listOfDigits}")
#asks for user input
number = input("Enter a positive integer : ")
#calls the function listOfDigits
listOfDigits(number)