为什么这不起作用?(学校项目顺便说一句)

发布于 2025-01-10 03:30:52 字数 3514 浏览 2 评论 0原文

import sys,time,random

typing_speed = 80 #wpm
def slow_type(t):
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush()
        time.sleep(random.random()*10.0/typing_speed)

slow_type("Hello which person do you want info for ")
inputs = input(
    "Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar             ")
if inputs == ('1'):
    inputs = input(
        "what info do you want.        1. overall life             2. accomplishments and obstacles.      3. His legacy   "
    )
    if inputs == ('1'):
        slow_type(
            "born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher,  he left the NOI to make a new group because he embraced a different type of Islam, sunni islam,    he died in febuary 21 on 1965 by assasins who were part of the NOI."
        )
    elif inputs == ('2'):
        slow_type(
            "Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back.   "
        )
if inputs == ('2'):
    inputs = input(
        "what info do you want. 1. Birth and age       2. Early Life.    3. Nba life      4. Later Life      5. Accomplishments and Accolades"
    )
    if inputs == ('1', '2', '3', '4', '5'):
        if inputs == ('1'):
            slow_type(
              "Kareem was born in New York during 1947 on the day of April 16th  with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
            )
        if inputs == ('2'):
            slow_type(
                "Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
            )
        if inputs == ('3'):
            slow_type(
                "In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
            )
        if inputs == ('4'):
            slow_type("o")

具体来说,由于某种原因,信息没有打印,请帮助 owo uwu 我是一个毛茸茸的猫女孩

import sys,time,random

typing_speed = 80 #wpm
def slow_type(t):
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush()
        time.sleep(random.random()*10.0/typing_speed)

slow_type("Hello which person do you want info for ")
inputs = input(
    "Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar             ")
if inputs == ('1'):
    inputs = input(
        "what info do you want.        1. overall life             2. accomplishments and obstacles.      3. His legacy   "
    )
    if inputs == ('1'):
        slow_type(
            "born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher,  he left the NOI to make a new group because he embraced a different type of Islam, sunni islam,    he died in febuary 21 on 1965 by assasins who were part of the NOI."
        )
    elif inputs == ('2'):
        slow_type(
            "Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back.   "
        )
if inputs == ('2'):
    inputs = input(
        "what info do you want. 1. Birth and age       2. Early Life.    3. Nba life      4. Later Life      5. Accomplishments and Accolades"
    )
    if inputs == ('1', '2', '3', '4', '5'):
        if inputs == ('1'):
            slow_type(
              "Kareem was born in New York during 1947 on the day of April 16th  with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
            )
        if inputs == ('2'):
            slow_type(
                "Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
            )
        if inputs == ('3'):
            slow_type(
                "In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
            )
        if inputs == ('4'):
            slow_type("o")

To be specific the info doesn’t print for some reason pls help owo uwu I’m a furry cat girl

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

禾厶谷欠 2025-01-17 03:30:52

它不起作用,因为你的逻辑。

if input == ('1', '2', '3', '4', '5'): 将始终返回 False 作为您的输入 变量永远不会是那个元组。您还覆盖了 inputs 变量,我会考虑重命名这些不同的变量。

我在那里做了一些改变。看一下并将其与您的代码进行比较。该代码运行良好(相对于您提供的代码)。

import sys,time,random

typing_speed = 80 #wpm
def slow_type(t):
    print('\n')
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush()
        time.sleep(random.random()*10.0/typing_speed)

slow_type("Hello which person do you want info for?")
inputs_alpha = input(
    "Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar\n--> ")
if inputs_alpha == '1':
    inputs = input(
        "what info do you want?\n1. overall life\n2. accomplishments and obstacles.\n3. His legacy\n--> "
    )
    if inputs == '1':
        slow_type(
            "born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher,  he left the NOI to make a new group because he embraced a different type of Islam, sunni islam,    he died in febuary 21 on 1965 by assasins who were part of the NOI."
        )
    elif inputs == '2':
        slow_type(
            "Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back.   "
        )
if inputs_alpha == '2':
    inputs = input(
        "what info do you want?\n1. Birth and age\n2. Early Life.\n3. Nba life\n4. Later Life\n5. Accomplishments and Accolades\n--> "
    )
    if inputs in ['1', '2', '3', '4', '5']:
        if inputs == '1':
            slow_type(
              "Kareem was born in New York during 1947 on the day of April 16th  with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
            )
        if inputs == '2':
            slow_type(
                "Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
            )
        if inputs == '3':
            slow_type(
                "In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
            )
        if inputs == '4':
            slow_type("o")

It doesn't work because your logic.

if inputs == ('1', '2', '3', '4', '5'): will always return False as your inputs variable will never be that tuple. You are also overwriting the inputs variable and I would consider renaming those distinct.

I made a few changes in there. Take a look and compare it to your code. This code is working just fine (relative to what you provided).

import sys,time,random

typing_speed = 80 #wpm
def slow_type(t):
    print('\n')
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush()
        time.sleep(random.random()*10.0/typing_speed)

slow_type("Hello which person do you want info for?")
inputs_alpha = input(
    "Type 1 For Malcom X, type 2 for Kareem Abdul-Jabbar\n--> ")
if inputs_alpha == '1':
    inputs = input(
        "what info do you want?\n1. overall life\n2. accomplishments and obstacles.\n3. His legacy\n--> "
    )
    if inputs == '1':
        slow_type(
            "born in may 19 1925 in Omaha Nebraska his parents both died when he was a young child and there wasn't anyone who really could take care of him so he spent much of his time bouncing around different foater homes, in 1952 he joined the nation of islam and became a preacher,  he left the NOI to make a new group because he embraced a different type of Islam, sunni islam,    he died in febuary 21 on 1965 by assasins who were part of the NOI."
        )
    elif inputs == '2':
        slow_type(
            "Some of his major accomplishments include preaching islam and the message that the oppressed ahould fight back.   "
        )
if inputs_alpha == '2':
    inputs = input(
        "what info do you want?\n1. Birth and age\n2. Early Life.\n3. Nba life\n4. Later Life\n5. Accomplishments and Accolades\n--> "
    )
    if inputs in ['1', '2', '3', '4', '5']:
        if inputs == '1':
            slow_type(
              "Kareem was born in New York during 1947 on the day of April 16th  with the birth name of Lew Alcindor Jr. the son of Fernando Lewis Alcindor., New York policeman and Cora Alcindor. Later in his life Lew Alcindor changed his name to Kareem Abdul-Jabbar, meaning noble servant of the powerful One. Kareem is still alive today and is 74 years of age"
            )
        if inputs == '2':
            slow_type(
                "Kareem/ Lew Alcindor was always the tallest person in his class. When Kareem turned 9 he was already 5’8”. When he hit eighth grade he was 6’8”. Lew was playing basketball since he was young. At power memorial academy, Lew had a high-school career that nobody could match. Lew brought his team to 71 straight wins and 3 straight city titles."
            )
        if inputs == '3':
            slow_type(
                "In 1969 the Milwaukee Bucks selected Lew Alcindor with the first overall pick in the NBA draft. Lew quickly became a star being second in the league in scoring and third in rebounding, Lew was named the NBA Rookie of The Year. In the following season Lew became better and better and the bucks added future Oscar Robertson to the roster, making the Bucks the best team in the league with a 66-16 record. The bucks won the ring that year and Lew won MVP. Later that Summer Lew converted to Islam and Changed his name to Kareem Abdul-jabbar. Kareem and the bucks got to the NBA finals that year but lost to the Celtics. Even with al the success with the bucks Kareem struggled to be happy. Later that off season demanded a trade to either The Lakers or the Nicks. The bucks complied and traded Kareem to the Los Angelos Lakers where he was paired with Magic Johnson, making the lakers by far the best team in the league. During the rest of Kareems career he dominated the NBA winning 5 more titles and wining 5 more MVPs."
            )
        if inputs == '4':
            slow_type("o")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文