Skip to content

How to save an INPUT in a list and save? #1660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Masabo1 opened this issue Aug 10, 2022 · 6 comments
Open

How to save an INPUT in a list and save? #1660

Masabo1 opened this issue Aug 10, 2022 · 6 comments

Comments

@Masabo1
Copy link

Masabo1 commented Aug 10, 2022

I'm very new to python and learning about the basics, I'll love to make a survey program that saves every entry of the INPUT function and send everything to a lost or dictionary and print all the info after the survey is completed?

@Masabo1 Masabo1 changed the title How to save an INPUT in a list and save How to save an INPUT in a list and save? Aug 10, 2022
@santoshdvc
Copy link

For Single Line input, space or comma separated.

#Numbers  
input_list = [int(i) for i in input().split()]
#Text 
input_list =  [i for i in input().split()]

@santoshdvc
Copy link

If multiline or dyanmic inputs :

#Create a empty list
input_list = []

#Append values anytime in program
input_list.append(input)

@Bhanuteja01
Copy link

@santoshdvc nice man

@Sd-Shiivam
Copy link

Sd-Shiivam commented Sep 22, 2022

if you want to give input one by one :

#Create a empty list
input_list = []
i=0
while i != 'stop':
    #take input
    data=input('Enter your data: ')
    if data != 'stop':    
        #Append values in integer formate
        input_list.append(data)
    elif data == 'stop':
        #Stop taking input
        i = data
  

print(input_list)

or you can try

main_list=[]
for _ in range(int(input("Number of items in list : "))):
    main_list.append(input(f'Enter list item {_} : '))

print(main_list)

@sayampradhan
Copy link
Contributor

# Storing the input in a list
list_of_input = []
input = input ("Give an input: ")

#appending the list with the input value
list_of_input.append(input)

@sayampradhan
Copy link
Contributor

#Taking input
user_input = input("Enter an input: ")

#List of saved inputs
list_of_inputs = []

#Appending the list with the inputs
list_of_inputs.append(user_input)

#Print the input
print(list_of_inputs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants