-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputToList.py
More file actions
18 lines (15 loc) · 1003 Bytes
/
InputToList.py
File metadata and controls
18 lines (15 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This Script For Input Values in List as User Input number of list item
import time
import sys
try:
UserList = []
print(UserList) # This code will print empty list
input_str = int(input('Please enter a Number Of List''\n')) # this will determine how many items will be in the list
print('please enter', input_str, 'Values') # this code will request number of item the determined before
for i in range(0, input_str): # this loop will keep going as user input
item = int(input()) # this variable will keep the value
UserList.append(item) # this code will append the values in UserList
print('user list is: ', UserList) # this code will print the list with new item as user input
time.sleep(5) # this code will wait 5 sec to see your input
except KeyboardInterrupt:
sys.exit() # this exception will wait until the user press Ctrl + C