cara membuat string di python
string = "this is string"
#or
string = 'this is also string'
PENGUIN OVERLORD
string = "this is string"
#or
string = 'this is also string'
#1) To type a string using the keyboard module:
#pip install keyboard
import keyboard
string = "This is what I typed"
keyboard.write(string)
#2) To check if an object is of the type 'str' (to check if the object is a string):
if type(object) == str:
#3) To print a string:
string = "This is displayed in your Big Black Console"
print(string)
# concatenating strings just means combining strings together
# it is used to add one string to the end of another
# below are two exmaples of how concatenation can be used
# to output 'Hello World':
# example 1:
hello_world = "Hello" + " World"
print(hello_world)
>>> Hello World
# example 2:
hello = "Hello"
print(hello + " World")
>>> Hello World
var1 = "A String"
type('Hellloooooo') # str
'I\'m thirsty'
"I'm thirsty"
"\n" # new line
"\t" # adds a tab
'Hey you!'[4] # y
name = 'Andrei Neagoie'
name[4] # e
name[:] # Andrei Neagoie
name[1:] # ndrei Neagoie
name[:1] # A
name[-1] # e
name[::1] # Andrei Neagoie
name[::-1] # eiogaeN ierdnA
name[0:10:2]# Ade e
# : is called slicing and has the format [ start : end : step ]
'Hi there ' + 'Timmy' # 'Hi there Timmy' --> This is called string concatenation
'*'*10 # **********
# Python String Operations
str1 = 'Hello'
str2 ='World!'
# using +
print('str1 + str2 = ', str1 + str2)
# using *
print('str1 * 3 =', str1 * 3)