List Being Read as String Not Int Python

PYTHON Type ERROR: STRING INDICES MUST BE INTEGERS-SOLUTION

          In [1]: string="typeerror"
In [2]: string['east']
Traceback (almost recent call last):
File "<ipython-input-eight-1b9006e9beb0>", line 1, in <module>
string['due east']
TypeError: string indices must be integers

          In [iii]: mystring="gratitude"
In [4]: mystring[0,5]
Traceback (most recent telephone call last):
File "<ipython-input-13-7c2881597196>", line ane, in <module>
mystring[0,v]
TypeError: cord indices must be integers
          In [five]: excerpt=0,5
In [six]: blazon(extract)
Out[six]: tuple
          In [vii]: mystring[extract]
Traceback (most contempo call final):
File "<ipython-input-16-308e1ed6160d>", line 1, in <module>mystring[extract] TypeError: string indices must be integers(not tuple)
          In [viii]: phone_book={          "Name": "Jennifer Aniston",
"Phone": "1800",
"Accost": "Apt20"
}
          In [9]: for   k in phone_book:          ...: print("Proper name:" + chiliad["Name"])
...: impress("Phone:" + g["Phone"])
...: print("Address:" + k["Address"])
Traceback (nigh contempo call concluding): File "<ipython-input-20-e5c1b8f425c3>", line two, in <module>
print("Name:" + k["Name"])
TypeError: cord indices must be integers
          In [10]: string[0]
Out[ten]: 't'
          In [eleven]: string1 = "Hullo in that location"
In [12]: len(string1)
Out[12]: 7
          In [thirteen]: mystring[0:5]
Out[xiii]: 'grati'
          In [14]: for k in phone_book:
...: print(grand)
...:
Proper name
Phone
Address
          In [15]: phone_book={
...: "Proper name": "Jennifer Aniston",
...: "Telephone": "1800",
...: "Address": "Apt20",
...: }
In [sixteen]: impress("Name:" + phone_book["Name"])
...: impress("Phone:" + phone_book["Phone"])
...: print("Address:" + phone_book["Address"])
Name:Jennifer Aniston
Phone:1800
Accost:Apt20

FOLLOW FOR More!

valentinodiany1971.blogspot.com

Source: https://medium.com/analytics-vidhya/python-type-error-string-indices-must-be-integers-solution-dc53df846b0f

0 Response to "List Being Read as String Not Int Python"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel