franckverrot commited on
Commit
c36189f
·
verified ·
1 Parent(s): b1a07eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -21,15 +21,18 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
21
  Returns:
22
  The ciphered string after performing a rotX transformation.
23
  """
24
- def rotate_char(c: str, shift: int) -> str:
25
- if 'a' <= c <= 'z':
26
- return chr((ord(c) - ord('a') + shift) % 26 + ord('a'))
27
- elif 'A' <= c <= 'Z':
28
- return chr((ord(c) - ord('A') + shift) % 26 + ord('A'))
29
- else:
30
- return c
31
 
32
- return "".join(rotate_char(c, arg2) for c in arg1)
 
 
 
 
 
 
 
 
33
 
34
 
35
  @tool
 
21
  Returns:
22
  The ciphered string after performing a rotX transformation.
23
  """
24
+ if arg2 is None:
25
+ raise ValueError("arg2 must be an integer, not None")
 
 
 
 
 
26
 
27
+ result = []
28
+ for char in arg1:
29
+ if char.isalpha():
30
+ base = ord('A') if char.isupper() else ord('a')
31
+ rotated = chr((ord(char) - base + arg2) % 26 + base)
32
+ result.append(rotated)
33
+ else:
34
+ result.append(char)
35
+ return ''.join(result)
36
 
37
 
38
  @tool