User Input For List | Python Programs
Вставка
- Опубліковано 18 жов 2024
- In this Python Programming video series we will discuss about how to take user input for list in detail.
Here we will see how we can take user input for list using for loop while loop and also how to input different type of input to list.
#PythonPrograms #List
For more free tutorials on computer programming
/ amulsacademy
/ amulsacademy
The Easiest and the most clear explaination I've seen on youtube. Tysm
Thank you 😊
Please do comeback mam@@AmulsAcademy
I really want to thank you, I am from Egypt, and I am not good at understanding most English accents
and I wanted to understand a certain part of a module, and I did not see such an easy way of explaining or a clear voice like you, thank you Amulya ♥️
You're very welcome! :)
Good morning Maam. Thanks for your modules. Loop was not cleared to me before your explanation. I am getting confident in the loop. You are doing a great job. I got stuck with the below when inputting any string showing errors.
import ast
list =[]
while True:
a = ast.literal_eval(input('Enter the items'))
list.append(a)
y = input('Would you like to continue entering numbers? press any key for yes and n for no')
if y=='n':
break
print(list)
Thank you very much for your lessons.
Thank you very much for this amazing tutorial now I can do some cool stuff after fully understanding the while and for loops... again Thank you very much.
Wow , Thanku mam for this beautiful explanation all doubts is cleared in a single tutorial video
Hey, great tutorial thanks for the upload. I've been struggling with this all day but i finally get it lol, and thanks again.
Thanks Amulya, you're a legend!
good teaching and easly understandig, in for loop in empty list
Thank you 😊
Muchas gracias por ayudarme Amulya si no era por ti, seguiria renegando con las listas. Te agradezco de corazon.
It really helped me
Thank you so much !!!
Thank you for your effort and clear explanation. This helps me so much at python
Thank you so much. Please provide us Data Science courses also mam.
It indeed helped me in understanding control on user inputs. Thanks.
Thank you for the help! Very concise video explanation
Thanks for the great explanation. It really helped me on understanding the full flow.
hello from us, thank u:)
Pleasure 😊
amazing video
Thank you ma'am
thanks maam for such a nice lesson....
congo for 101k....
keep making such videos, thank you once again
Thank you so much :)
I got headache to make a list by user. I found the solution by this video. Thank you❤️
Pleasure :)
Very good explanation
Thank you so much, sis. Saved my life!
😊😊😊
How she saved your life 🤔🤔
@@priyanshusharma2144 Was nearing a deadline, and was panicking since everything was unfamiliar. Amulya explained everything in a crystal clear way, which made me picked up everything in minutes. I recommend you watch her tutorials if you have any interest. Really a lifesaver.
Ohk but how she helps you, menas now what are you doing have get your placement
@@priyanshusharma2144 I didn't quite get you. 😅
You are the best sweat heart... Thanks
Thank you 😊
Your explain well, you can help summarise GUI and py to exe
Really nice voice and helpful concept
Thank you 😊
Thanks a lot!!!
Thanks, amulyia.
That was great , thank you.
this class is helpful
but we can do it in another way
a=input("enter your numbers")
s=a.split()
print(s)
i think it will be helpful too
👍🏻
It really helped me
Thank you so much
Pleasure :)
Amulya shetty good one again
Thank you :)
What if i dont want to know how many, because i want to print the length of the imputs from the user? For instace, add a number, do you want to add more (y/n). Then it will loop back. If i press n, then i will have a series of fucntions.
hug thanks from Brazil dud
Thank you 😊
Best videos :)
Thank you 😊
Thanks loads..
How do u do this with a space bar ends input , when i do this loop it adds a number to a list once [4] then the rest show up like 4
Hiii!, love it. what if i want different commands from same user_input symbol? like if user_input press "yes" it will give one clue, if user input give "yes" for the second time then it will give 2nd clue in the print. How can I do that? I am stuck :(
You can use loop :)
thanks, mam for the lesson but how do you
use that code then add it up?
I didn’t get you ..
Thank you
Hey, if i want the user to have the choice to remove something from the list aswell, how do i do that?
Amulya when will be the python new batch starts
Soon :)
@@AmulsAcademy is this paid course?
How to give heterogeneous input for list in single line from user end?
n=int(input(“Enter number of elements : “))
Lst=[int(input(“Enter element : “)) for x in range(0,n)]
Will this work?
Instead you can write like this!!!
n=int(input("Enter number of elements : "))
Lst=[n for x in range(0,n)]
print(Lst)
Yes you can :)
@irene if you want different input in list then you need to use input function inside the list.
@@AmulsAcademy yup
@@AmulsAcademy this will make a list of first n-1 integers
thank u❤❤❤❤❤❤
while executing some programs on online compiler why it shows EOFError.While same program is running on another compiler.Why this could happen?
I got this part but if I want to create n number of list for example: pls enter the number of list you want:2
Enter the length : 4
A b c d
[A b c d]
Enter the length : 4
B c d e
[B c d e]
How to make it like this
Simply I want to ask how to create more than 1 list using user input
Let's suppose list has 2 only two options. I want user to select either option 1 or 2 as input and then proceed with my program to gather more import input from user then how should I go about it?
what if i have to find the maximum value from a multiple user inputs what will be the code?
Yeah, but what do I do if the program isn't supposed to ask for a value on how many times it is supposed to run. I know I would use a while loop obviously but how do I know when to break the loop!
We can use eval in input :)
Yes :)
Asusual 👌👍
Thank you :)
suppose if we want to give the inputs as a list format 10 20 22 like this in the output.....how to write that.?
for example we need to take 3 input values in a list format at the time of execution
a=10 20 22
b=51 21 23
Hey did u got code for u r qstion .i too searching for that .did u found it share it pls
I am typing lst = []
it is giving syntax error please tell why ?
But I didn't get error
If the input already exist or not what will be the programme
But in this type of user input all the elements in the list will be of same type..........but according to definition of list it can contain the elements of multiple types......how can we take input in which our list contain elements of multiple types
for chuck yen times ok mam got it
Do the same for indepth about lambda , map
Sure :)
Hi , In user input I provided 5 elements but in the output its giving 3 elements only.
Give me the program please :)
@@AmulsAcademy list1=[ ]
while True:
element=int(input ('Enter element'))
list1.append(element)
Choice=input('want to stop?if yes press yes')
If choice=='yes'
Break
Print('list of elements ' , list1)
@@AmulsAcademy it's working
@@Ramesh-rp6jq @Amulya's Academy
import ast
list1=[ ]
while True:
element=ast.literal_eval(input ('Enter element: '))
list1.append(element)
choice=input('want to stop? enter yes: ')
if choice =='yes':
break
print('list of elements ' , list1)
For the above code ,its taking a floating point value and integer value but its not taking a character . Can you tell me if I have made a mistake?
I got my mistake I was not entering the character in between the " " (for example : " ant ")
Hi mam
I found that 'ProgramsAndMe' is a channel that channel copying ur videos mam so be care about it mam
You are boss
How can we take user input of char, float, int values simultaneously??
You need to use eval function or literal_eval function from ast module :)
@@AmulsAcademy how does it work?
Can you please explain alil?
How find duplicate in this method
Do you want to find duplicate values in list ?
for some reason eval is not working in jupyter. Is anyone else tried eval in jupyter?
COMMENDABLE. Could not be better
How to add n elements in list without pressing enter n times?
You can enter values using space then you can separate that 😊
@@AmulsAcademy i can't press space n times
Hello i need to make a program that is supposed to do this:
For the first question, your program should randomly select a planet, display its name, and ask the user for its position in the solar system, with respect to the Sun.
Example: Correct answer
Note: This example illustrates how your program should work. The output of your program will depend on the randomly-selected planet and the user’s input, so it will be different each time you execute it.
The program displays a prompt and waits for keyboard input What is the position of Earth, relative to the Sun?
The user types in a reply 3
The program displays a message that the user’s answer is correct That is correct.
Earth is planet number 3 from the Sun.
Example: Incorrect answer
Note: This example illustrates how your program should work. The output of your program will depend on the randomly-selected planet and the user’s input, so it will be different each time you execute it.
The program displays a prompt and waits for keyboard input What is the position of Mars, relative to the Sun?
The user types in a reply 5
The program displays a message that the user’s answer is incorrect, along with the correct answer That is not correct.
Mars is planet number 4 from the Sun.
Please can you help me
I am also very bad at python and very new
import random
from random import randint
planets = ["Mercury", "Venus", "Earth","Mars", "Jupiter", "Saturn","Uranus", "Neptune"]
value = random.choice(planets)
print("What is the position of",value +",relative to the sun?")
planet = input()
index = randint(0,7)
planet = planets[index]
print("That is correct.",planet +" is planet number",randint +"from the sun")
THis what I put
Execute this program and see what you will get 😊
@@AmulsAcademy thanks miss!
What if i want to insert decimal values in the list? 😅
Float ?
@@AmulsAcademy Yes I got it, thank you..🤙💫
👍
Thank you :)
you can say nicely....
Can we use map function for this list
Yes you can :)
when continuation of doubly linked list ?
Tomorrow :)
😃👍👍👍👍👍👍👍👍
what about for nexted list of two dimension pls
I will try to make videos on that :)
I am not first
not showing face
yen lmao sry
Are you girl or boy? I am confused 😁
Girl 😊
@@AmulsAcademy fall in love 🤭 for voice
thank you