Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Dev/name-ascii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Python3 code to demonstrate working of
# Convert String list to ascii values
# using list comprehension + ord()

# initializing the list
test_list = ['welcome', 'to', 'hacktoberfest']

# printing the original list for clear identification
print("The original list : " + str(test_list))

# Convertion starts here
# used ord()
res = [ord(ele) for sub in test_list for ele in sub]

# Final out put will be provided by this code
print("The ascii list is : " + str(res))

###########################################
##### O u t p u t s a m p l e #####
# The original list : ['welcome', 'to', 'hacktoberfest']
# The ascii list is : [119, 101, 108, 99, 111, 109, 101, 116, 111, 104, 97, 99, 107, 116, 111, 98, 101, 114, 102, 101, 115, 116]
###########################################
19 changes: 19 additions & 0 deletions Dev/word_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# L E T S C O U N T W O R D S O N A S E N T E N C E #

# string initializing is in here
test_string = "Have a wonderful day!"

# Returning the original sentence
print ("The original string is : " + test_string)

# Counting the words begins here...
res = test_string.count(" ")+1

# printing Output
print ("The number of words in string are : " + str(res))

###############################################################
#### below is a sample demonstration of above code snippet ####
# The original string is : Have a wonderful day!
# The number of words in string are : 4
###############################################################