পাইথন প্রোগ্রাম স্ট্রিং যোগদান এবং একটি স্ট্রিং বিভক্ত করার জন্য অন্তর্নির্মিত ফাংশন প্রদান করে।
split Str.split() join Str1.join(str2)
অ্যালগরিদম
Step 1: Input a string. Step 2: here we use split method for splitting and for joining use join function. Step 3: display output.
উদাহরণ কোড
#split of string str1=input("Enter first String with space :: ") print(str1.split()) #splits at space str2=input("Enter second String with (,) :: ") print(str2.split(',')) #splits at ',' str3=input("Enter third String with (:) :: ") print(str3.split(':')) #splits at ':' str4=input("Enter fourth String with (;) :: ") print(str4.split(';')) #splits at ';' str5=input("Enter fifth String without space :: ") print([str5[i:i+2]for i in range(0,len(str5),2)]) #splits at position 2
আউটপুট
Enter first String with space :: python program ['python', 'program'] Enter second String with (,) :: python, program ['python', 'program'] Enter third String with (:) :: python: program ['python', 'program'] Enter fourth String with (;) :: python; program ['python', 'program'] Enter fifth String without space :: python program ['py', 'th', 'on', 'pr', 'og', 'ra', 'm']
উদাহরণ কোড
#string joining str1=input("Enter first String :: ") str2=input("Enter second String :: ") str=str2.join(str1) #each character of str1 is concatenated to the #front of str2 print(“AFTER JOINING OF TWO STRING ::>”,str)
আউটপুট
Enter first String :: AAA Enter second String :: BBB AFTER JOINING OF TWO STRING ::>ABBBABBBA