Posts

12th_replace_first_letter_in_capital

  mystring = " learn python " print ( mystring . title ())

11th_remove_word_from_string

  text = input ( " Enter the string: " ) word = input ( " Enter a word to delete: " ) text = text . replace ( word , "" ) print ( text )

10th_comma_separator

  str = input ( " Enter a string: " ) print ( list ( str )) #print(tuple(str)) #print(set(str))

9th_remove_duplicates_from_list

  def remove_duplicates ( lst ):     return list ( set ( lst )) my_list = [ 1 , 2 , 4 , 2 , 1 , 4 , 5 ] print ( " Original list: " , my_list ) new_list = remove_duplicates ( my_list ) print ( " list after removing duplicate elements: " , new_list )

8th_has_duplicate_check_function

  def has_duplicates ( v ): #Called function     c = 0     for i in range ( len ( v )):         for j in range ( i + 1 , len ( v )):             if v [ i ]== v [ j ]:                 c = c + 1     if c > 0 :         print ( True )     else :         print ( False ) v =[ 1 , 2 , 3 , 2 , 3 ] #main() function print ( " List is: " , v ) has_duplicates ( v ) #Calling function

7th_is_sorted_function_check_list

  def is_sorted ( stuff ):     for i in range ( len ( stuff )- 1 ):         if stuff [ i ]> stuff [ i + 1 ]:             return False     else :         return True numbers =[ 1 , 2 , 3 , 4 , 0 ] print ( is_sorted ( numbers ))

6th_palindrome

  def palindrome ( s ):     rst = ""     for i in range ( len ( s )):         rst = s [ i ]+ rst     if s == rst :         return True     else :         return False st = input ( " Enter a string: " ) r = palindrome ( st ) if r == True :     print ( " The given string is palindrome " ) else :     print ( " The given string is not palindrome " )