Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. #from re import *
  2.  
  3. def reverse_print(str):
  4.     new_str = [obj for obj in reversed(str)]
  5.     new_str = "".join(new_str)
  6.     print 'Orginal string: ',first_string
  7.     print 'New_str: ', new_str
  8.  
  9. def search_for_chars(search_str,input_str):
  10.     input_str_reversed = [obj for obj in reversed(input_str)]
  11.     found_chars = []
  12.     not_found = []
  13.     for char in search_str:
  14.         if char in input_str_reversed:
  15.             print 'Before delete',reverse_print(input_str_reversed)
  16.             input_str_reversed.remove(char)
  17.             found_chars.append(char)
  18.             print 'After delete',reverse_print(input_str_reversed)
  19.         else:
  20.             not_found.append(char)
  21.  
  22.     return input_str,input_str_reversed,found_chars,not_found
  23.  
  24.  
  25.  
  26.  
  27.  
  28. first_string = "hej pa dig du fule"
  29. second_string = "idg eluf hej ap"
  30.  
  31.  
  32. input_str,output_str,found_chars,not_found = search_for_chars('hej duq',first_string)
  33. print "\n\n\n"
  34. print input_str
  35. reverse_print(output_str)
  36. print 'found_chars: ',found_chars,'\n Not found:',not_found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement