Тёмный
No video :(

Input a List using Loops in Python 

Neso Academy
Подписаться 2,6 млн
Просмотров 34 тыс.
50% 1

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 23   
@b07_ashishsuradkar49
@b07_ashishsuradkar49 Год назад
Great video sir.
@lionelfaith3646
@lionelfaith3646 10 месяцев назад
n=int(input("enter the number of elements of your list: ")) #input data from the user and convert it to integer type numbers=[] #create an empty list for i in range(n): #iterate my list from index 0 to n-1 and repeat the block of instructions below for each i x = int(input(f"enter the elements for numbers {[i]}: ")) #store the elements of the list from user in x variable numbers.append(x) #add each element at the end of the list numbers print(numbers) #output the new list
@user-ev5fj1rm3y
@user-ev5fj1rm3y 7 месяцев назад
I don't get where the i came from in for loop
@kaifXD
@kaifXD 3 месяца назад
@@user-ev5fj1rm3ywe just take a variable i to loop thru.. in this case for loop
@handle_gc
@handle_gc 9 месяцев назад
This can also be achieved using below code for storing items as string not int. items = input("Enter multiple items: ") list = items.split() print(list)
@AmanKumar-fj2lz
@AmanKumar-fj2lz 6 месяцев назад
Tems??
@AmanKumar-fj2lz
@AmanKumar-fj2lz 6 месяцев назад
No its still a string.. Python3IDE(Python 3.7) running! enter the 3 digit number234 ['234'] Pytho3IDE run end!
@wisdomoregfx
@wisdomoregfx 5 месяцев назад
You are a life saver. Thanks ❤
@lionelfaith3646
@lionelfaith3646 10 месяцев назад
@Neso academy Great video , it helps me a lot as usual but what about if we want a list which is a collection of different types of items ? because with the example in the course all the items of our list must be an integer
@jingersatuh6322
@jingersatuh6322 6 месяцев назад
Clear explanation.
@muhammadbinuzair2101
@muhammadbinuzair2101 4 месяца назад
It was really helpful Thank you
@user-xc7uz5xg9y
@user-xc7uz5xg9y 6 месяцев назад
Sir, instead of using for loop to input a list we can use split function... numbers = input().split()
@sgiri2012
@sgiri2012 Год назад
Thank you for your class sir
@alimuhtasham4045
@alimuhtasham4045 19 дней назад
what about this code ? numbers = [ ] for i in range(3): x = input('Enter the element: ') numbers.append(x) print(numbers)
@_AhmedKhawar
@_AhmedKhawar 13 дней назад
The input function always returns a value as a string. If we are to obtain numbers then we'll have to convert the type of the obtained item to integer (int) or float. we can also do, numbers = [ ] for i in range (3): x = input() y = int(x) numbers.append(y) The method in the video is for getting numbers as input and type is being converted in the same line in which input is being taken.
@tecolote8566
@tecolote8566 5 месяцев назад
NICE!!
@pawansaxena1304
@pawansaxena1304 5 месяцев назад
sir i have a doubt can't we directly use eval function for entering the list sir i had tried it and also work so why to use loop method
@fifthamendment1
@fifthamendment1 10 месяцев назад
Thanks for the vid. Just a suggestion… what if you need to input hundreds of numbers? The user is not going to want take a count of each number and possibly miscount. Might be better just to input numbers and type END when finished.
@sagnikadhya3425
@sagnikadhya3425 7 месяцев назад
I guess using while loop would be better then
@internetguy3978
@internetguy3978 2 месяца назад
Please use an ide... Command prompt sucks
@nesoacademy
@nesoacademy 2 месяца назад
We started using VS Code after covering the basics.
@pgkgaming4229
@pgkgaming4229 3 месяца назад
❤❤❤🎉
Далее
Input a List using split() Method in Python
8:27
Просмотров 34 тыс.
Construction site video BEST.99
01:00
Просмотров 288 тыс.
for Loop vs. while Loop in Python
8:45
Просмотров 29 тыс.
10 Python Comprehensions You SHOULD Be Using
21:35
Просмотров 140 тыс.
Solve any Star Pattern program in Python
18:44
Просмотров 920 тыс.
Changing List Items in Python
7:08
Просмотров 14 тыс.
Python lists, sets, and tuples explained 🍍
15:06
Просмотров 259 тыс.
6 Tips to write BETTER For Loops in Python
9:19
Просмотров 248 тыс.