Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if statement in for loop
#7
I would be really surprised if isalpha doesn't work. You can test easily enough using the examples in metulburr's post.

You should be trying to debug this problem yourself. The first thing I would have done was start with a much shorter and more interesting story, at least from a programming point of view.
story = 'aA 12 !@#$%^&*()+=-~'
for letter in story:
    if letter.isalpha():
        print(letter, letter.)
If this didn't give me the expected results I would test if isalpha worked as expected.
story = 'aA 12 !@#$%^&*()+=-~'
for letter in story:
    print(letter, 'isalpha =', letter.isalpha())
Depending on the results I would check the documentation to determine if I was doing the loop right or using isalpha() correctly.

After doing that research I might consider posting a question on the forum. My research would probably solve the problem and I wouldn't have to wait for an answer. If I still had questions I would ask a better question and be in a better position to understand the answer.
Reply


Messages In This Thread
if statement in for loop - by researcher123 - Oct-01-2020, 02:53 PM
RE: if statement in for loop - by bowlofred - Oct-01-2020, 03:22 PM
RE: if statement in for loop - by deanhystad - Oct-01-2020, 03:41 PM
RE: if statement in for loop - by metulburr - Oct-01-2020, 04:25 PM
RE: if statement in for loop - by researcher123 - Oct-01-2020, 04:30 PM
RE: if statement in for loop - by bowlofred - Oct-01-2020, 04:57 PM
RE: if statement in for loop - by deanhystad - Oct-01-2020, 05:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Python code: While loop with if statement HAMOUDA 1 572 Sep-18-2023, 11:18 AM
Last Post: deanhystad
  Multiply and Addition in the same loop statement with logic. joelraj 2 1,032 Feb-02-2023, 04:33 AM
Last Post: deanhystad
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 5,842 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  how to create pythonic codes including for loop and if statement? aupres 1 1,922 Jan-02-2021, 06:10 AM
Last Post: Gribouillis
  Help: list comprehension for loop with double if statement mart79 3 2,422 May-04-2020, 06:34 AM
Last Post: buran
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,195 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619
  Trying to include an If statement in my While Loop junkankit 3 2,951 Jan-31-2019, 10:06 AM
Last Post: buran
  How get attributes of maps from loop statement LB_994 3 3,156 Aug-21-2018, 03:24 PM
Last Post: LB_994

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020