Chapter 9 Exercise 2 solution : Python tutorial 133

preview_player
Показать описание
Guys please help this channel to reach 20,000 subscribers. I'll keep uploading quality content for you.

Python is easy programming language to learn and anyone can learn it, and these tutorials are 100% free in hindi.

You can share this playlist with your brother, sisters and friends. This will surely add some values to their life.

If you follow this complete playlist of python tutorial surely you will learn everything about python programming language.

This is solution of exercise 2 of chapter 9

Рекомендации по теме
Комментарии
Автор

Harshit is doing great job . He is amazing and extraordinary.I am a big fan of his.
Little shorter code would be:
def num_to_str(t):
return [str(i) for i in t if type(i) in (int, float)]

pranayrajwade
Автор

Bhai sahab Mera sahi ho gaya ek baar mein! Luv u sir😍

AshishKumar-dlmc
Автор

how we print the integer list inside the list[1, 2, 3]

shwetpandey
Автор

You have given the input here urself after writing the function.
But Suppose I want to take inputs from user ( user can give any type of input including int, float, char, list, etc).Then how can we write the code for this exercise?

abhisarikasingh
Автор

can you suggest a way if user input is required in that case i think each input type will be of string type

newdreamza-z
Автор

Brother we didn't declared any empty list for storing...so where does it storing ....is it storing in the same list ?

behindthescene
Автор

sir jo list list k andr bani hwi hai wo output m Q nhi aai [1, 2, 3]

zybi
Автор

Sir please reply me if user input is required how to do it will too complicated for me

nct-nocopyrightthumbnail
Автор

def func(ara):
ara2 = [str(i) for i in ara if (type(i) == float or type(i) == int)]
return ara2
ara = [1, 2, True, False, 1.0, [1, 2, 3], {4, 5, 6}]
Numbers = []
Numbers = func(ara)
print(Numbers)
#LoveFromBangladesh

shamimsarker
Автор

Is wrote if type(i) is int . I did not gave ==. The correct output is coming but is it right??

jstinsane
Автор

list_ = [[True, False], ['1', '2', '3'], [1, 2.0, 3]]
list2_ = [i for i in list_ for j in i if type(j) == int or type(j) == float]
print(list2_)

apna-bolly-tolly-wood
Автор

*_Sir your source code doesn't exist and the dropbox page is showing error like Error (404)._*

avilashbhowmik
Автор

Is it necessary to check the type of data

behindthescene
Автор

sir ji why didn't u use tuple and dictionary in list ? i am stuck at it i actually managed to get list"s element in the form of complete tuple but how can i access the data of tuple in a list??? this answer was ordinary.

razzakahmad
Автор

sir, but print(type(string_func(['name', 'false', [1, 2, 3], 1, 1.0, 2]))) output: <class:'list'> de rha hai na ki <class :'str'>

DeepakSharma-milo
Автор

Sir i have a question
Boolean value ke baad ka list [1, 2, 3] kyu output mai nhi aaya only 1, 1.0, 3 hi aaya float aaya thik hai 1, 3 no bhi but list mai no. hai then why this value not shown in output

vedjain
Автор

Good Morning!! Sir!! Why there is no '2' in the output. After all, 2 is also a number that should be changed to string?

ARGamingMusicVlog
Автор

Sir Please Help Me Out !!!


Problem :-


Mene kuch dino se try kar raha hu ki jab bhi me list bana tha hu input function aur split method use karke aur phir me uss me int value input kar tha hu toh woh string me hota hai. aur jab me usse int()
function use kar ke int me change kar tha hu toh muje error ata hai.



Practically Occurring Problem :-


Numbers = input(" Enter Any Number : ").split(", ") # for eg i have input 1, 2, 3, 4


# Lists Would Be display as Numbers = ['1', '2', '3', '4']


# When i try To Change It in integer



Numbers = int(Numbers)
print(Numbers)


Output :-

Error!! Occurs !!!



Please Help To solve this doubt !!!!

privateStream
Автор

Number_List1 = [True, False, [1, 2, 4], 1, 1.0, 3]
def
return [str(Each_Element) for Each_Element in Number_List1 if type(Each_Element) is int or type(Each_Element) is float]

hybridhouse
Автор

i am getting an error as, 'list_name is not callable'

Maneesh