“cuerda de pitón” Código de respuesta

Cómo crear cadena en Python

string = "this is string"
#or
string = 'this is also string'
PENGUIN OVERLORD

pitón

#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)
Amateur developer

cuerda de pitón

#Strings in python are surrounded by either single quotation marks, or double quotation marks.
print("This is a string")
print('i am also a string')
Programmer of empires

cuerda de pitón

string = 'amaama'
half = int(len(string) / 2)
 
if len(string) % 2 == 0:  # even
    first_str = string[:half]
    second_str = string[half:]
else:  # odd
    first_str = string[:half]
    second_str = string[half+1:]
 
# symmetric
if first_str == second_str:
    print(string, 'string is symmertical')
else:
    print(string, 'string is not symmertical')
 
# palindrome
if first_str == second_str[::-1]:  # ''.join(reversed(second_str)) [slower]
    print(string, 'string is palindrome')
else:
    print(string, 'string is not palindrome')

cuerda de pitón

>>> 'Py' 'thon'
'Python'
Itchy Ibis

cuerda de pitón

#You can assign a multiline string to a variable by using three quotes:

a = """Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua."""
print(a)
Asif Iqbal Paracha

Respuestas similares a “cuerda de pitón”

Preguntas similares a “cuerda de pitón”

Más respuestas relacionadas con “cuerda de pitón” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código