ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

Input a List using Loops in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ส.ค. 2024

ความคิดเห็น • 23

  • @b07_ashishsuradkar49
    @b07_ashishsuradkar49 ปีที่แล้ว +4

    Great video sir.

  • @lionelfaith3646
    @lionelfaith3646 10 หลายเดือนก่อน +1

    @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

  • @user-xc7uz5xg9y
    @user-xc7uz5xg9y 6 หลายเดือนก่อน

    Sir, instead of using for loop to input a list we can use split function...
    numbers = input().split()

  • @muhammadbinuzair2101
    @muhammadbinuzair2101 4 หลายเดือนก่อน

    It was really helpful
    Thank you

  • @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 ❤

  • @sgiri2012
    @sgiri2012 ปีที่แล้ว

    Thank you for your class sir

  • @jingersatuh6322
    @jingersatuh6322 6 หลายเดือนก่อน

    Clear explanation.

  • @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

  • @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

  • @alimuhtasham4045
    @alimuhtasham4045 17 วันที่ผ่านมา

    what about this code ?

    numbers = [ ]
    for i in range(3):
    x = input('Enter the element: ')
    numbers.append(x)
    print(numbers)

    • @_AhmedKhawar
      @_AhmedKhawar 11 วันที่ผ่านมา

      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.

  • @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

  • @tecolote8566
    @tecolote8566 5 หลายเดือนก่อน +1

    NICE!!

  • @internetguy3978
    @internetguy3978 2 หลายเดือนก่อน +1

    Please use an ide... Command prompt sucks

    • @nesoacademy
      @nesoacademy  2 หลายเดือนก่อน

      We started using VS Code after covering the basics.

  • @pgkgaming4229
    @pgkgaming4229 3 หลายเดือนก่อน

    ❤❤❤🎉