Spaces:
Sleeping
Sleeping
Kevin Maik Jablonka
commited on
Commit
·
638348e
1
Parent(s):
b19335d
random fix
Browse files
app.py
CHANGED
@@ -21,9 +21,10 @@ def update_index(direction, current_index, output_text):
|
|
21 |
if direction == 0:
|
22 |
# Random number
|
23 |
new_index = random.randint(0, len(data) - 1)
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
output_text = data[int(new_index)]
|
28 |
return new_index, output_text
|
29 |
|
|
|
21 |
if direction == 0:
|
22 |
# Random number
|
23 |
new_index = random.randint(0, len(data) - 1)
|
24 |
+
else:
|
25 |
+
new_index = current_index + direction
|
26 |
+
# Ensure the new index is within bounds
|
27 |
+
new_index = max(0, min(new_index, len(data) - 1))
|
28 |
output_text = data[int(new_index)]
|
29 |
return new_index, output_text
|
30 |
|