Commit ee42155d authored by Phondanai Khanti's avatar Phondanai Khanti
Browse files

Add quiz

parent 5faa0f80
results = []
with open("words.txt") as f:
for word in f:
word_cleaned = word.strip().lower() # remove trailling \n, and make it all lowercase
if word_cleaned == word_cleaned[::-1]:
results.append(word_cleaned) # keep a result in results list
# one-liner
results_oneline = [word.strip().lower() for word in list(open('words.txt')) if word.strip().lower() == word.strip().lower()[::-1]]
print("Palindrom One-Liner")
# one-liner with len more than 2 characters
results_oneline_more_than_two = [word.strip().lower() for word in list(open('words.txt')) if word.strip().lower() == word.strip().lower()[::-1] and len(word.strip().lower()) > 2]
print("Palindrom One-Liner word more than 2 characters")
This diff is collapsed.
print("XMas tree generator")
level = input("How many level: ")
if level.isdigit():
level = int(level)
for i in range(1,level * 2, 2):
print(("*" * i).center(level*2))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment