diff --git a/Dev/name-ascii.py b/Dev/name-ascii.py new file mode 100644 index 0000000..b9a9caa --- /dev/null +++ b/Dev/name-ascii.py @@ -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] +########################################### diff --git a/Dev/word_counter.py b/Dev/word_counter.py new file mode 100644 index 0000000..318e691 --- /dev/null +++ b/Dev/word_counter.py @@ -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 +###############################################################