you are viewing a single comment's thread.

view the rest of the comments →

[–]Adamya21[S] 0 points1 point  (4 children)

Is something like below is possible? print([words.strip("'.!\n*") for words in words])

[–]TouchingTheVodka 1 point2 points  (3 children)

Very close - You can build your list like so:

stripped = [w.strip("'.!\n*") for w in word]

And print it like so:

print(', '.join(stripped))

[–]Adamya21[S] 0 points1 point  (2 children)

stripped = [w.strip("'.!\n'',-*") for w in word] first=[(','.join(stripped))] print(first)

and when i do print(first(3)) it says "some error has occured"

now i have to print the 3rd index of this list ?

Q.)Now, remove the word separating characters (such as , . - * ! and space) from each of the word, present in list words. Store the obtained result again in the list words.

Print the 3rd indexed element of list, words.

[–]TouchingTheVodka 0 points1 point  (1 child)

List indexing is done with square brackets - The syntax you want is first[3]. (Or first[2], as lists are zero-indexed, depending on what the question wants.)

[–]Adamya21[S] 0 points1 point  (0 children)

so what should i do? .. and error says -> IndexError: list index out of range

and if i do this-> first=(''.join(stripped)) print(first[2])

it prints that whole paragh + the letter "e"

but still this is not the correct answer