Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Last active December 10, 2015 19:52
Show Gist options
  • Select an option

  • Save 1dolinski/532dba8bc54c654a8b15 to your computer and use it in GitHub Desktop.

Select an option

Save 1dolinski/532dba8bc54c654a8b15 to your computer and use it in GitHub Desktop.
#Write a program that will take an input string and will yield another (new) string
#which includes only letters andnumbers and removes all other characters
#Your program should then print both the old(input) string and the new one
#after the omissions. Think of how you can do this minimally.
#Check BIFs that can take in a character/string and decide the type of it
#Look up python String Methods (4.7.1 String Methods) in the documentation
user_input=input('please enter anything: ')
punctuation= "!,./\[]?><':;@)("
words=list(punctuation)
# OLD
#for x in puncuation:
# user_input.replace(puncuation,'')
# NEW
for x in punctuation
user_input = user_input.replace(x,'')
new_list=[]
words=name.split
new_list.append(words)
#for x in words:
print(new_list)
print(user_input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment