File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
[2.2] Fundamentals Exam - Exercises/[1.4] Final Exam - Retake Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ main_msg = input ()
2
+ command = input ()
3
+
4
+ while command != "Reveal" :
5
+ command_type , * info = command .split (":|:" )
6
+ error_found = False
7
+
8
+ if command_type == "ChangeAll" :
9
+ main_msg = main_msg .replace (info [0 ], info [1 ])
10
+
11
+ elif command_type == "Reverse" :
12
+ substring = info [0 ]
13
+
14
+ if substring not in main_msg :
15
+ print ("error" )
16
+
17
+ error_found = True
18
+ else :
19
+ main_msg = main_msg .replace (substring , "" , 1 ) + substring [::- 1 ]
20
+
21
+ elif command_type == "InsertSpace" :
22
+ idx_to_insert = int (info [0 ])
23
+ main_msg = main_msg [:idx_to_insert ] + " " + main_msg [idx_to_insert :]
24
+
25
+ if not error_found :
26
+ print (main_msg )
27
+
28
+ command = input ()
29
+
30
+ print (f"You have a new text message: { main_msg } " )
You can’t perform that action at this time.
0 commit comments