import random
for i in range(15):
a = random.choice(["вперед", "назад", "вверх", "вниз"])
print(a)
import random
words = {'вперед', 'назад', 'вверх', 'вниз'}
a = None
for _ in range(15):
a = random.choice(tuple(words - {a}))
print(a)
import random
for _ in range(15): print(a := random.choice(tuple({'вперед', 'назад', 'вверх', 'вниз'} - {locals().get('a')})))