Created
July 23, 2020 19:11
-
-
Save kavilivishnu/6f7ade1121a50042f31678621edff339 to your computer and use it in GitHub Desktop.
String Reverse and Swap case.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Stack Data Structure | |
""" | |
class Stack: | |
def __init__(self): | |
self.number=[] | |
def push(self,number): | |
self.number.append(number) | |
def pop(self): | |
return self.number.pop() | |
def peek(self): | |
return self.number[-1] | |
def reverse_print(stack, input_string): | |
for i in range(len(input_string)): | |
s.push(input_string[i]) | |
prnt_rev = "" | |
while not s.is_empty(): | |
prnt_rev += s.pop() | |
return prnt_rev | |
stack = Stack() | |
input_string = "HELLOWORLd" | |
print(reverse_print(stack, input_string.swapcase())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment