#Python 2, 64 63 bytes
Python 2, 64 63 bytes
Anonymous function with arguments n
and k
, returns the list to output.
lambda n,k:[[i,'Shaggy'][i%k<1or`k`in`i`]for i in range(1,n+1)]
Alternatively, a function which prints to STDOUT
for the same bytecount:
def f(n,k,i=1):exec"print[i,'Shaggy'][i%k<1or`k`in`i`];i+=1;"*n