String Methods in Python (Part 4)

preview_player
Показать описание
Python Programming: String Methods in Python (Part 4)
Topics discussed:
1. join() Method for Strings in Python.
2. replace() Method for Strings in Python.

Music:
Axol x Alex Skrindo - You [NCS Release]

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

Wow, sir.. you are the greatest teacher on this planet. Love you 😍

rforrana
Автор

'Neso Academy is the best Academy.'

klevver
Автор

Sir in replace method in last example you write s = "l love to eat strawberries."
After s.replace(' ', '-', 2) output
'l-love-to eat mangoes.' output should be 'l-love-to eat strawberries.' is it print mistake or how mangoes replace strawberries I did not get please tell

harishmahajan
Автор

Answer for 1st question
'Neso Academy is the best Academy'
Answer for 2nd question
Option B i.e., No
Because intergers are not iterables.

sowmyasri
Автор

you're the greatest teacher i never seen before

izgjocu
Автор

'Neso Academy is the Academy.' 10:25

thtutorials
Автор

1. Suppose that a list contains two integers as follows.
1. l = [1, 2]
1. can we use the join method to join the integers of the above list without any space between them
1. yes
2. no
l = [1, 2]
' '.join(l)
TypeError Traceback (most recent call last)
in <cell line: 2>()
1 l = [1, 2]
----> 2 ' '.join(l)

TypeError: sequence item 0: expected str instance, int found

reason for the error on the above code is because the .join() method is only capable to work on the string data type in a iterable.

if we want to apply the .join() on the iterable, we need to convert the data to strings explicitly by using map function.

l = [1, 2]
''.join(map(str, l))
#o/p: '1 2'

somanathking
Автор

why we cant join the integers in the list?

mohammedisarezwani
Автор

Join method didn't explained clearly 😔

cshmbkj
Автор

HW 2: No, because integers are not iterables.

klevver
Автор

No because string method contains only characters

Ayyappaswamy
join shbcf.ru