Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble in lists
#1
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
Reply
#2
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.
Reply
#3
(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.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trouble displaying items from lists Liquid_Ocelot 8 6,375 May-18-2017, 01:37 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020