Skip to main content

Featured

Write a Python Program to find palindrome of a given string

If you reverse the word then you get the same word that word is palindrome. def   palindrome ( str ):     pointer =  str       rev_str =  reversed (pointer)       if   list (pointer) ==  list (rev_str):         print ( "It is palindrome" )       else :         print ( "It is not palindrome" )  palindrome( 'level' ) palindrome( 'madam' ) palindrome( 'life' ) palindrome( 'refer' ) Output:  It is palindrome It is palindrome It is not palindrome It is palindrome

List in python

           One of the most fundamental data structures in any language is the array. Python doesn't have a native array data structures,but it has the list. A list is mutable it means the content of the list are changed

 list1= ['tech', 'language', 28, 32,]

 List is one of the most used data type in python and us an ordered sequence of elements. All the elements in a list need not be of same data type. List is created by placing all the items inside a square brackets [], separated by commas

Lets see some basic list Operator:

1) length- find length of the list

2) concatenation- concatenate two lists

3) Repetition- repeat the item multiple times

4) Append-  add an element to the end of the list

5) Insert- insert an item at the defined index

6) Extend- add all elements of a list to the another list

7) Remove- remove an item from the list

8) Pop- removes an element at the given idex

9) Clear- removes all item from the list

10) Index- return the index of the first match item

Example:

list1 = ['tech','language',28,38,'hi']
list2=["good"]
print (len(list1))
print(list1+list2)
print(['hi']*4)
list1.append(234)
print(list1)
list1.insert(2,'python')
print(list1)
list1.remove('python')
print(list1)
print(list1.pop())
print(list1)



If you have any doubt in list Operator feel free to comment!! If you like this post comments and say your wishes

Comments

Popular Posts