Python question!

Asked 2 years ago, Updated 2 years ago, 42 views

I'm writing the code below.

The first time you run it, the result is

It's a.

That's it.

It's m.

It's like this.

When you press the switch, you want to go to abcd[3] and create a loop that expresses the next three.


abcd=["a", "a", "m", 'ㅅ'"a", "h", 'ㅂ'"n", ',", ',, ,', ',, ',, ㅏ, 11, 11", ']

#Initial consonants

for i in range(0,3):

    if abcd[i]=='a':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='n':
        print ("It's 입니다")

    elif abcd[i]=='d':
        print ("")"

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='l':
        print ("R" in Korean)

    elif abcd[i]=='m':
        print ("m"

    elif abcd[i]=='ㅂ':
        print ("b"

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='ㅅ':
        print ("s" in Korean)

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='':
        print ("It's O")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='k':
        print ("I'm LOL")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='h':
        print ("I'm H")

        #Neutral

    elif abcd[i]=='a':
        print ("It's h")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='-':
        print ("-is")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("I am")

        #Jongsung
    elif abcd[i]=='a':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='n':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='d':
        print ("")"

    elif abcd[i]=='l':
        print ("R" in Korean)

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='m':
        print ("m"

    elif abcd[i]=='ㅂ':
        print ("b"

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='ㅅ':
        print ("s" in Korean)

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='k':
        print ("I'm LOL")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]==''':
        print ("It's 입니다")

    elif abcd[i]=='h':
        print ("I'm H")

    elif abcd[i]==' ':
        print ("spacing")

    elif abcd[i]=='1':
        print ("number 1")

python raspberry-pi

2022-09-21 21:46

2 Answers

I'm not sure what you're trying to ask.

First of all, you can simply change the code you wrote with respect! as follows:

for i in range(0, 3):
    print (abcd[i]+')

If you want to take three characters at a time, given a list of characters and an index, you can create a function like this.

def The next three characters are (character list, index number):
    Next three-letter list = statement list [Index number: Index number +3]
    For letter in the following three-letter list
        print (letter+')

abcd=["a", "a", "m", 'ㅅ'"a", "h", 'ㅂ'"n", ',", ',, ,', ',, ',, ㅏ, 11, 11", ']
i = 0
while i < len(abcd):
    The next three letters are (abcd, i)
    input ("Check the following three characters:")
    i += 3
print ('end')


2022-09-21 21:46

I'll give you a hint in Korean. Hangul is more programmable than you think because there is a Unicode in the world.

# Python3 criteria.
import math

# Using Unicode code points, select the elementary/middle/final character of one Korean alphabet.
def chojoongzong(geulza) :

    # Minimal Exception Handling 1
    if len(geulza) > 1 :
        print('>>>>>>>> Error! Please enter only one character.')
        return None

    # Minimal exception handling 2
    cheotza = order(u'ga') # order() is a Python built-in function.
    kkeutza = order(u'he') # Read the document.
    yigeulza = ord(geulza)
    if yigeulza < cheotza or yigeulza > kkeutza :
        print('>>>>>>>> Error! Please enter a full 1 character between 'a' and 'he')
        return None

    # Son of a letter is full list of Han-gul from. find a index
    # if you received the word 'each' This value is 1. It is 'Street' 'each' : I'd say.
    yigeulza = yigeulza - cheotza

    # 이 목록 역시 임의로 생성할 수 있습니다. A Study on the one!
    choseongs = ['ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ']
    joongseongs = ['ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ']
    zongseongs = [None, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ']

    # 21 medial vowels, sometimes a consonant placed under a is 28.
    # So, one of the initial consonants, such as for How many letters to share?
    # The answer : a total of 588.
    choseonggateungeulzas = len(joongseongs) * len(zongseongs)

    # at a given initial consonants from how we're going to get?
    # the index is between 0 and 1177, was ㄲ ... or I an initial consonant, 588 587, dude.
    cho = math.floor(yigeulza / choseonggateungeulzas)
    print (choseongs [cho] + '.')

    # How do we get neutrality from a given index?
    # The index is 0, 0+588, 0+588+588,... All of these guys are neutral. (Go, go, go, go, go...)
    # But the index is 1, 1+588, 1+588+588,... They're all neutered
    # But the index is 28, 28+588, They're probably neutral. (Gae, wake up, my,...)
    # Roll Crayon Shin-chan to find regularity and find the general term.
    joong = math.floor((yigeulza % choseonggateungeulzas) / len(zongseongs))
    print (joongsongs [joong] + '.')

    # How do we get species from a given index?
    # Index is 1, 1+28, 1+28+28,... All of these people have a family name of '.
    # There may not be any specifications, so I added a separate treatment.
    zong = math.floor(yigeulza % len(zongseongs))
    if zongseongs[zong] != None :
        print (zongsongs [zong] + '.')

# It's a bit more than 50 lines of code, including the annotation, and it works well.
# If you don't believe it, try executing code on the right.
chojongzong (u'lol)
chojoongzong (u'no')
chojongzong (u' is')
chojongzong (u'de)
chojoongzong(u'?')


2022-09-21 21:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.