Strings

Run Settings
LanguagePython
Language Version
Run Command
# Python ----> Interpreter (line by line translation)------> Bite code-------> cpython VM (runs the code)------> Prints # Python interpreter + cpython VM is what we download, there are other machines online : PyPy (written in python), Jython (Java), cpython (in C)) user_name_1, user_name_2 = "Ribhu", "Sanhitaa" #multiple variable assignment print("Hello! " + user_name_1 + " and " + user_name_2) #string concatenation print("Hello! {} and {}".format(user_name_1,user_name_2)) #format method on strings print(f"Hello! {user_name_1} and {user_name_2}") #formatted string in print #strings are immutable, ordered, iterables new_name = user_name_2[::-1] #user_name_2[start : end (exclusive) : stepover] print((user_name_1+ " " +user_name_2).title()) print(new_name[-2]) #new_name[i] i is the index print(" Hello ".strip()) #removes leading and trailing white spaces print("Hello "* 3) new_name_2 = "Ri,b h u" new_lst = new_name_2.split(",") # s.split("delimiter") print(new_lst) print("".join(new_lst)) # joins the list elements using "delimiters".join(list) print(len(user_name_1) == len(user_name_2)) # len function evaluates the strings print("R" in "Ribhu")
Editor Settings
Theme
Key bindings
Full width
Lines