I’m new to Python and programming in general. Therefore, I’m doing the Python 3 course here at codecademy.
I’m now at the “coded communication” task (https://www.codecademy.com/courses/learn-python-3/informationals/python3-coded-communication):
Here, a ciper should be decoded by a “vigenere cipher” with the keyword phrase “friends”.
I really don’t understand why the following could does not work correctly and these mysterious “u”'s appear…
I would be really glad, if anyone can help me!
Here is the problematic code:
hmessage = "dfc jhjj ifyh yf hrfgiv xulk? vmph bfzo! qtl eeh gvkszlfl yyvww kpi hpuvzx dl tzcgrywrxll!" abc = "abcdefghijklmnopqrstuvwxyz" key = "friends" dechiff = "" keystep = 0 def decode(code, abc, key): global dechiff global keystep for i in code: if keystep < len(key): if i in abc: dechiff += abc[abc.find(i)-abc.find(key[keystep])] keystep += 1 else: dechiff += i keystep += 1 else: keystep = 0 dechiff += abc[abc.find(i)-abc.find(key[keystep])] keystep += 1 decode(hmessage, abc, key) print(dechiff)