Skip to content

Instantly share code, notes, and snippets.

@KingCprey
Last active May 22, 2017 16:04
Show Gist options
  • Save KingCprey/3db46eae8faf2b7546619cdeb76e8e33 to your computer and use it in GitHub Desktop.
Save KingCprey/3db46eae8faf2b7546619cdeb76e8e33 to your computer and use it in GitHub Desktop.
Bro do you even chanka
import os
def gimmeinput(prompt):
try:return raw_input(prompt)
except:return input(prompt)
try:
while True:
i=gimmeinput("How many cha chas u want? ")
try:
chia=int(i)
chanka="Cha"
if chia>0:
chanka+="cha"*chia
chanka+="chanka"
chankalen=len(chanka)
i=gimmeinput("Print {0} chars to screen? y/n".format(chankalen))
if i.lower()=="y":
print(chanka)
i=gimmeinput("Write to file (y/n)? ")
if i.lower()=="y":
p=gimmeinput("Where to? ")
doit=not os.path.exists(p)
if not doit:
i=gimmeinput("File exists. Overwrite file (y/n)? ")
doit=i.lower()=="y"
if doit:
print("Writing {0} chars to file {1}".format(chankalen,p))
try:
with open(p,'w')as out:
out.write(chanka)
i=gimmeinput("Open in notepad (y/n)? ")
if i.lower()=="y":os.system("notepad.exe {0}".format(p))
except:
print("Error writing")
except ValueError as ve:
print("That ain't a number u twonk")
except KeyboardInterrupt:
print("Bye ya tw@")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment