+ 1

Why is it that the input ab is the same thing twice

import random input = str(input("")) key = random.randint(123, 9999999) def encode(v): v = v * key v =+ key v = str(v) v = v + ' ' return(v) a = encode(1) b = encode(2) c = encode(3) d = encode(4) output = input.replace("a", a).replace("b", b) print(output)

19th Jun 2020, 8:01 PM
Pringles
Pringles - avatar
1 Odpowiedź
0
You overwrite v with the constant value of key instead of adding it: v += key Random key with seed within the function helps too...
19th Jun 2020, 11:26 PM
Sandra Meyer
Sandra Meyer - avatar