Login
Remember
Register
All Courses
Ask a Question
Questions
Unanswered
Ask a Question
Blog
Tutorials
Interview Questions
Back
Login
Explore Courses
Blog
Tutorials
Interview Questions
community
Machine Learning
I have written a python script which gets all the...
I have written a python script which gets all the word starting from letter specified. But when i run it the program gives some words then crashes with giving error-'IndexError :string index out of range.
I have written a python script which gets all the word starting from letter specified. But when i run it the program gives some words then crashes with giving error-'IndexError :string index out of range.
0
votes
2
views
asked
Jun 24, 2021
in
Machine Learning
by
Anurag Sinha
(
120
points)
recategorized
6 days
ago
by
hemant.sharma
My script:
a=open("textfile.txt",'r+','encoding="ANSI")
word_starts_with=input("Enter any letter")
for line in a:
word=line.strip()
if word[0] ==word_starts_with:
print(word)
#python
#indexerrror
#programming
Please
log in
to add a comment.
Please
log in
to answer this question.
0
Answers
Related questions
0
votes
1
answer
Python error "IndexError: list index out of range"
asked
Jan 18, 2020
in
Python
by
Rajesh Malhotra
(
19.9k
points)
python
0
votes
1
answer
IndexError: tuple index out of range --— Python
asked
Aug 24, 2019
in
Python
by
Sammy
(
47.6k
points)
python
mysql
0
votes
1
answer
IndexError: list index out of range and python
asked
Aug 22, 2019
in
Python
by
Sammy
(
47.6k
points)
python
indexing
0
votes
1
answer
Python: IndexError: list index out of range
asked
Aug 5, 2019
in
Python
by
Aarav
(
11.4k
points)
python
indexing
0
votes
1
answer
Capitalize the first letter of both words in a two word string
asked
Jul 10, 2019
in
R Programming
by
Ajinkya757
(
5.3k
points)
rprogramming
string
31k
questions
32.8k
answers
501
comments
693
users
All categories
Python
(3.4k)
Java
(2.2k)
SQL
(1.6k)
Linux
(373)
Big Data Hadoop & Spark
(1.3k)
Data Science
(3.3k)
R Programming
(867)
C Programming
(35)
DevOps and Agile
(2.9k)
Docker
(61)
AI and Deep Learning
(1.4k)
Machine Learning
(1.2k)
AWS
(2.5k)
Azure
(1.6k)
GCP
(226)
RPA
(616)
Selenium
(212)
Software Testing
(59)
Blockchain
(436)
Salesforce
(823)
Others
(585)
BI
(1.9k)
IoT
(24)
Web Technology
(1.5k)
Cyber Security
(359)
Digital Marketing
(331)
Technology Trends
(121)
SEO
(105)
Informatica
(22)
UI UX
(153)
Electric Vehicle
(24)
Investment Banking
(56)
Supply Chain Management
(30)
...