You are using the file name as the name of the directory and then trying to write to it as if it was a file. You need to create the folder without the appended file name, thus:
import os
mypath ="C:/Users/admin/Desktop/scripts26/folder"
if not os.path.exists(mypath):
os.makedirs(mypath,0755)
print"Path is created"
fname = mypath + "/" + "test.txt"
with open(fname,"w") as x:
x.write("This is a boy")