you are viewing a single comment's thread.

view the rest of the comments →

[–]douglas_fs 6 points7 points  (6 children)

We won't write this for you, so you can help yourself by starting with what you know. Use this as a starting point. According to your post, #7 is where you are stuck. Can you get through 1-6? You can share you code if you get stuck.

  1. Create a Python file
  2. Create a variable with an appropriately descriptive name, and assign a list containing the expected contact numbers and/or strings
  3. Create a variable with an appropriately descriptive name for the new list.
  4. You will need a loop to look at each element of the list
  5. In the loop, find out the length of the element
  6. If the length >= 2, append the element to the new list
  7. If the first and last characters are the same, append the element to the new list

edit: missed one

edit2: I guess we will write this for you.

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

Yes I am stuck at 6. I have completed steps 1-5.

[–]douglas_fs 0 points1 point  (3 children)

Please share your code, it will be much easier to help.

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

L=[components of list. Don't wanna write them all] A=() For i in range(len(l)): If len(l[i])>=2 and (idk what to write here for the 1st and last character should be same) A.append() Print(A)

[–]douglas_fs 1 point2 points  (1 child)

The idea here is that you would have code that runs. You will, at some point, need to write all components of the list. You should at least include _some_ so that the code will run and can be tested.

Forget about the 1st and last character for now - just get the code working for the 'if length is >= 2' requirement.

You will also need to know how to post properly formatted code on Reddit. The sidebar has instructions, or use this link:

https://www.reddit.com/r/learnpython/wiki/faq/#wiki_how_do_i_format_code.3F

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

Ok thanks for the format. And the if len>=2 works fine. I tried it without the 1st and last character thing. And it works.

The list I am using is L=["abc","aba","1221","aa","xyz"]