Skip to content

Commit

Permalink
Merge pull request geekcomputers#511 from nayaknameet/master
Browse files Browse the repository at this point in the history
Fixes 3 files
  • Loading branch information
geekcomputers authored Jul 22, 2019
2 parents d2def07 + 8803fe4 commit 52cfe85
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
22 changes: 16 additions & 6 deletions Palindrome_Checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@

givenPhrase = input("\nPlease input a phrase:(Press ENTER to use the sample phrase) ")

if givenPhrase == "" or not givenPhrase.strip():
if givenPhrase == "":
print("\nThe sample phrase is: {0}".format(samplePhrase))
phrase = samplePhrase
else:
phrase = givenPhrase

string = phrase.lower()
phrase = phrase.lower()

if string == string[::-1]:
print("\nWow!, The phrase is a Palindrome!")
else:
print("\nSorry, The given phrase is not a Palindrome.")

length_ = len(phrase)
bol_ = True

# check using two pointers, one at beginning
# other at the end. Use only half of the list.
for items in range(length_//2):
if phrase[items] != phrase[length_ - 1 - items]:
print("\nSorry, The given phrase is not a Palindrome.")
bol_ = False
break

if bol_:
print("\nWow!, The phrase is a Palindrome!")
13 changes: 12 additions & 1 deletion Print_List_of_Even_Numbers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# INPUT NUMBER OF EVEN NUMBERS
def print_error_messages():
print("Invalid number, please enter a Non-negative number!")
exit()


try:
n=int(input('Amount: '))
except ValueError:
print_error_messages()

n=int(input('Amount: '))
start=0

if n < 0:
print_error_messages()

for i in range(n):
print(start)
start+=2
13 changes: 12 additions & 1 deletion Print_List_of_Odd_Numbers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# INPUT NUMBER OF ODD NUMBERS
def print_error_messages():
print("Invalid number, please enter a Non-negative number!")
exit()


try:
n=int(input('Amount: '))
except ValueError:
print_error_messages()

n=int(input('Amount: '))
start=1

if n < 0:
print_error_messages()

for i in range(n):
print(start)
start+=2

0 comments on commit 52cfe85

Please sign in to comment.