Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit c969801

Browse files
Merge pull request #1 from ankitdobhal/master
adding new files (branch with master)
2 parents 405f564 + a1cb98a commit c969801

File tree

2 files changed

+65
-13
lines changed

2 files changed

+65
-13
lines changed

Basic-Scripts/balanced_paranthesis.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
openBracketList = ["[", "{", "("]
2+
closeBracketList = ["]", "}", ")"]
3+
4+
5+
def check_parentheses(data: str) -> str:
6+
"""
7+
check_parentheses() : Will take a string as an arguement and each time when an open parentheses is encountered
8+
will push it in the stack, and when closed parenthesis is encountered,
9+
will match it with the top of stack and pop it.
10+
11+
Parameters:
12+
data (str): takes a string.
13+
14+
Returns:
15+
str: Returns a string value whether string passed is balanced or Unbalanced.
16+
"""
17+
stack = []
18+
for index in data:
19+
if index in openBracketList:
20+
stack.append(index)
21+
elif index in closeBracketList:
22+
position = closeBracketList.index(index)
23+
if (len(stack) > 0) and (
24+
openBracketList[position] == stack[len(stack) - 1]
25+
):
26+
stack.pop()
27+
else:
28+
return "Unbalanced"
29+
if len(stack) == 0:
30+
return "Balanced"
31+
else:
32+
return "Unbalanced"
33+
34+
35+
if __name__ == "__main__":
36+
37+
data = input("Enter the string to check:\t")
38+
result = check_parentheses(data)
39+
print(result)
40+

Contribution.md

+25-13
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22
If this is your first time to open source contribution in python So that I have created this repo for all the you to start contributing.
33

44
# How to contribute!
5-
## Steps:
6-
* fork the [repository](https://github.com/ankitdobhal/Python-Scripts)
7-
* Clone the fork [repo](https://github.com/ankitdobhal/Python-Scripts)
8-
(git clone https://github.com/ankitdobhal/Python-Scripts)
9-
* Create new branch
10-
(git checkout -b <Your-Branch-Name>)
11-
* Add files in scripts folder
12-
(git add <your-contribution>)
13-
* Add a commit message !
14-
(git commit -a -m "<Added your message>")
15-
* Push changes
16-
(git push origin)
17-
* Create pull requests
5+
6+
## Steps:
7+
- First commment on the issue in which you want to work upon.
8+
- Issue-1 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/91
9+
- Issue-2 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/92
10+
- Issue-3 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/93
11+
- Issue-4 : https://github.com/ankitdobhal/Awesome-Python-Scripts/issues/94
12+
13+
- Fork the [repository](https://github.com/ankitdobhal/Awesome-Python-Scripts)
14+
15+
- Clone the fork [repo](https://github.com/ankitdobhal/Awesome-Python-Scripts)
16+
- git clone https://github.com/ankitdobhal/Awesome-Python-Scripts
17+
- Create new branch
18+
- git checkout -b <Your-Branch-Name>
19+
20+
- Add Scripts related to your respective issues.
21+
- git add <your-contribution>
22+
23+
- Add a commit message !
24+
- git commit -a -m "<Added your message>"
25+
- Push changes
26+
- git push origin
27+
28+
- Create pull requests
29+
- [Try to Mention the related issue for your PR]

0 commit comments

Comments
 (0)