#Basic_String_Operations # <<—this is a comment #can use double or single quotes” astring = “Hello world!” astring2 = ‘Hello world!’ #enclose single quotes inside double quotes print(“single quotes are ‘ ‘”) #print the length of a string print(len(astring)) #print index of string w/ first occurrence of the letter #”o” print(astring.index(“o”)) #count the number of “ls” …
Tag Archives: string
Python String Formatting
data = (“John”, “Doe”, 53.44) format_string = “Hello %s %s. Your current balance is $%s.” print(format_string % data)