Can I make this shorter in anyway? Using Python

if choice == 1:
choice_value = ‘1’
elif choice == 2:
choice_value = ‘2’
elif choice == 3:
choice_value = ‘3’
elif choice == 4:
choice_value = ‘4’
elif choice == 5:
choice_value = ‘5’
elif choice == 6:
choice_value = ‘6’
elif choice == 7:
choice_value = ‘7’
elif choice == 8:
choice_value = ‘8’
elif choice == 9:
choice_value = ‘9’
else:
choice_value = ‘10’

1 Like

Given that choice is number, and your code simply gives a string representation of that number,

choice_value = str(choice)
1 Like

Thanks Very Much Appreciated

2 Likes