Python Forum
Trouble in lists - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Trouble in lists (/thread-16366.html)



Trouble in lists - erfanakbari1 - Feb-25-2019

Hey guys , I'm a beginner at Python & I have taken a python course in which i am given some exercises to solve . unfortunately working with strings and lists made me confused so that I don't know how to do these exercises . I will be so happy if you can help me with this .

1.Convert the string to list.


2.Display the first element and last element of list.


3.Display the elements except first and last elements in the list.

4.Display the length of the list.

5.Convert the list back to string and display them.

6.Convert the string to list with respect to spaces i.e ['hello','world'] for input 'hello world'

Thanks for your help guys


RE: Trouble in lists - Larz60+ - Feb-25-2019

Confused or not, show what you have tried.
We will be glad to help if you show proper effort, but will not write code for you.


RE: Trouble in lists - perfringo - Feb-26-2019

(Feb-25-2019, 11:20 AM)erfanakbari1 Wrote: 1.Convert the string to list.
2.Display the first element and last element of list.
3.Display the elements except first and last elements in the list.
4.Display the length of the list.
5.Convert the list back to string and display them.
6.Convert the string to list with respect to spaces i.e ['hello','world'] for input 'hello world'

1. Use one of built-in functions
2. Use subscription
3. Use slicing
4. Use one of built-in functions
5. Use one of built-in functions
6. Use one of string methods

Python names are quite descriptive therefore finding needed on should be quite simple.