Project Euler Problem #277
Creating a list out of a string
wordList = []
for i in &quot;UDDDUdddDDUDDddDdDddDDUDDdUUDd&quot;:
   wordList.append(i)

can be shortened to:
wordList = list(&quot;UDDDUdddDDUDDddDdDddDDUDDdUUDd&quot;)

Algorithm
The first idea is to check the sequence letter by letter. This is more efficient than generating the sequence for a number x and then see if it matches the target sequence.
To find the number that matches Dd starting from 3, it would be:

x = 3
3 % 3 == 0, so it matches D
x = 3 / 3 = 1
1 doesn't match d, so try next number
x = 3 + 1 = 4
4 doesn't match D
x = 4 + 1 = 5
5 doesn't match D
x = 5 + 1 = 6
6 matches D
x = 6 / 3 = 2
2 matches d
Solution is 6

Second idea is to filter out numbers that cannot be part of the solution.
In the previous example, numbers 4 and 5 can be filtered out. Similarly to your n += 3. Let's see some examples:
Numbers that match the prefix D:
3,6,9,12,15,18,21...

Numbers that match the prefix DD:
9,18,27,36...

Numbers that match the prefix DDD:
27,54,81,...


Each sequence is a subset of the previous.
Numbers in the sequence differ by \$3^i\$, with i starting from 1.

Numbers that match the prefix U:
4,7,10,13,16,19,21,...

Numbers that match the prefix UU:
7,16,25,34,...

Numbers that match the prefix UUU:
25,52,79,...


Each sequence is a subset of the previous.
Numbers in the sequence differ by \$3^i\$, with i starting from 1.

Same for sequences that match d. Let's see a mixed prefix.
Numbers that match the prefix D:
3,6,9,12,15,18,21...

Numbers that match the prefix DU:
12,21,30,...


Each sequence is a subset of the previous.
Numbers in the sequence differ by \$3^i\$, with i starting from 1.