Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. cost = 0
  2. initial_string = ""
  3. initial_list = []
  4.  
  5. def get_all_substrings(input_string):
  6. length = len(input_string)
  7. return [input_string[i:j+1] for i in range(length) for j in range(i,length)]
  8.  
  9. #This takes the input indefenitely
  10. while True:
  11. input_string = input("Please Enter the String")
  12. if input_string in set(get_all_substrings(initial_string)):
  13. cost+=15
  14. else:
  15. cost+=10
  16. initial_string = initial_string + input_string
  17.  
  18. print(" Input string : {} \n Current String:{} \n Cost:{}".format(input_string,initial_string,cost))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement