English 中文(简体)
我为什么在案文中确定wel声的指挥系统没有显示?
原标题:why is my command block for identifying vowels in text not showing?
text = """
Inserting comments into program code is normal practice.
As a result, every programming language has some way of allowing comments to be inserted into programs.
The objective is to add descriptions to parts of the code, either to document it or to add a description of the implemented algorithm."
"""

vowel =  a  or  e 
for i, vowel in enumerate(text):
    if vowel == text:
       print(f"Vowel {vowel} found in position {i}")
    else:
       continue

I am trying to create this block where it should show which of the vowels was found and its position in the text, however, when I run the program it doesn t execute anything. I started recently and I m trying to understand why it s not working...

问题回答
text = """
Inserting comments into program code is normal practice.
As a result, every programming language has some way of allowing comments to be inserted into programs.
The objective is to add descriptions to parts of the code, either to document it or to add a description of the implemented algorithm."
"""

# iterable of vowels
vowels = set( aeiou )

# for every character in the text
for i, char in enumerate(text):

    # report if character is in vowels
    if char in vowels:
        print(f"Vowel {char} found at position {i}")

海事组织比用数百条几乎相同的线铺开奥ole,更容易阅读。

import json

def mark_chars(data:str, chars:str) -> dict:
    report = {c:[] for c in chars}
    chars  = set(chars)
    
    for i, char in enumerate(data):
        if char in chars:
            report[char].append(i)
            
    return report

    
text = """
Inserting comments into program code is normal practice.
As a result, every programming language has some way of allowing comments to be inserted into programs.
The objective is to add descriptions to parts of the code, either to document it or to add a description of the implemented algorithm."
"""

marks = mark_chars(text,  ae )
        
print(json.dumps(marks, indent=4))

I am trying to create this block where it should show which of the vowels was found and its position in the text, however, when I run the program it doesn t execute anything.

这个问题是可以确定的。

更改<代码>=至in

第9行:

if vowel == text:

:

if vowel in text:




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签