“für char in String python” Code-Antworten

So erhalten Sie einen Brief von einem String -Python

Random = "Whatever"#you can put anything here
words2 = Random.split(" ")
print('number of letters:')#you can delete this line...
print(len(Random))#and this one. these lines just Tell you how many 
#letters there are
while True:#you can get rid of this loop if you want
    ask = int(input("what letter do you want?"))
    print(Random[ask-1])
Tough Termite

Python Char an

>>> s = "python"
>>> s[3]
'h'
>>> s[6]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[0]
'p'
>>> s[-1]
'n'
>>> s[-6]
'p'
>>> s[-7]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> 
Cirex

Python für Zeichen in String

# Python program to iterate over characters of a string
  
# Code #1
string_name = "geeksforgeeks"
  
# Iterate over the string
for element in string_name:
    print(element, end=' ')
print("\n")
  
  
# Code #2
string_name = "GEEKS"
  
# Iterate over index
for element in range(0, len(string_name)):
    print(string_name[element])
Supreme Oreo

für char in String python

string = "some string"

for x in string:
  	print(x, end=' ')
Helpless Hedgehog

Ähnliche Antworten wie “für char in String python”

Fragen ähnlich wie “für char in String python”

Weitere verwandte Antworten zu “für char in String python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen