Skip to content

Commit 4c57734

Browse files
Exercise_7
1 parent 2e19115 commit 4c57734

File tree

3 files changed

+60
-8
lines changed

3 files changed

+60
-8
lines changed

.idea/workspace.xml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Level_1/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,27 @@ def two_dimens_arr(x, y):
153153
print(l1)
154154
return
155155
two_dimens_arr(4, 4)
156+
157+
158+
# ========================= Question_7: ===========================================
159+
# Write a program that accepts a comma separated sequence of words as input and
160+
# prints the words in a comma-separated sequence after sorting them alphabetically.
161+
# Suppose the following input is supplied to the program:
162+
# without,hello,bag,world
163+
# Then, the output should be:
164+
# bag,hello,without,world
165+
#
166+
# Hints:
167+
# In case of input data being supplied to the question, it should be assumed to be a console input.
168+
169+
def prog_3():
170+
x = input()
171+
list_ = []
172+
173+
for a in x.split(","):
174+
list_.append(a)
175+
list_.sort()
176+
str_ = ",".join(list_)
177+
print(list_)
178+
print(str_)
179+
return

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,35 @@ x.printString()
144144
* * *
145145

146146

147+
## Question_6: ##
148+
**Description:**
149+
150+
Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated\
151+
sequence after sorting them alphabetically.\
152+
Suppose the following input is supplied to the program:\
153+
* without,hello,bag,world
154+
Then, the output should be:\
155+
* bag,hello,without,world\
156+
157+
**Hints:**
158+
In case of input data being supplied to the question, it should be assumed to be a console input.
159+
160+
```python
161+
def prog_3():
162+
x = input()
163+
list_ = []
164+
165+
for a in x.split(","):
166+
list_.append(a)
167+
list_.sort()
168+
str_ = ",".join(list_)
169+
print(list_)
170+
print(str_)
171+
return
172+
prog_3()
173+
```
174+
* * *
175+
147176
## Question_6: ##
148177
**Description:**
149178

@@ -172,4 +201,3 @@ def two_dimens_arr(x, y):
172201
two_dimens_arr(4, 4)
173202
```
174203
* * *
175-

0 commit comments

Comments
 (0)