PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Make the code that will, by randomly adding or subtracting 1, reach the previously set either minimum or maximum
value, starting with user input that is a number between those values.
Please, enter three numbers in the order as follows: smallest first, then the biggest, and finally, a number
with value between first two entries.
"""
from random import choice
#taking user's input
val_min = int(input())
val_max = int(input())
start = int(input())
operation = [1, 2]
if type(start) == int and type(val_min) == int and type(val_max) == int:
if val_min < start < val_max:
while True:
count = choice(operation)
if count == 1:
start += 1
print(start)
elif count == 2:
start -= 1
print(start)
if start == val_min:
print("Lower limit has been reached.")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run