From 1f0fc94f6623d8a4047f477edc0873743d23f7da Mon Sep 17 00:00:00 2001 From: root Date: Wed, 23 Oct 2019 12:43:07 +0530 Subject: [PATCH] String-join-split --- Programs/String-join-split.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Programs/String-join-split.py diff --git a/Programs/String-join-split.py b/Programs/String-join-split.py new file mode 100644 index 0000000..070ba04 --- /dev/null +++ b/Programs/String-join-split.py @@ -0,0 +1,29 @@ +# Python program to split a string and +# join it using different delimiter + +def split_string(string): + + # Split the string based on space delimiter + list_string = string.split(' ') + + return list_string + +def join_string(list_string): + + # Join the string based on '-' delimiter + string = '-'.join(list_string) + + return string + +# Driver Function +if __name__ == '__main__': + string = 'Rahul Goyal' + + # Splitting a string + list_string = split_string(string) + print(list_string) + + # Join list of strings into one + new_string = join_string(list_string) + print(new_string) +