import random

def a():
    str1 = '''Do people need to compare themselves with others in order to appreciate what they have?
        Are widely held views often wrong, or are such views more likely to be correct?
        Is there any value for people to belong only to a group or groups with which they have something in common?
        Is it always best to determine one's own views of right and wrong, or can we benefit from following the crowd?
        Is it more valuable for people to fit in than to be unique and different?
        Are people more likely to be productive and successful when they ignore the opinions of others?
        Should we pay more attention to people who are older and more experienced than we are?
        Should society limit people's exposure to some kinds of information or forms of expression?
        Can a group of people function effectively without someone being in charge?
        Is it important to question the ideas and decisions of people in positions of authority?
        Should society limit people's exposure to some kinds of information or forms of expression?
        Is education primarily the result of influences other than school?
        Should schools help students understand moral choices and social issues?
        Is it always better to be original than to imitate or use the ideas of others?
        Is it better for a society when people act as individuals rather than copying the ideas and opinions of others?
        Is creativity needed more than ever in the world today?
        Can people ever be truly original?
        Do we put too much value on the ideas or actions of individual people?
        Does planning interfere with creativity?
        Do people truly benefit from hardship and misfortune?
        Do we really benefit from every event or experience in some way?
        Do people place too much emphasis on winning?
        Do people learn more from losing than from winning?
        Does true learning only occur when we experience difficulties?
        Does being ethical make it hard to be successful?
        Can knowledge be a burden rather than a benefit?
        Is persistence more important than ability in determining a person's success?
        Is the effort involved in pursuing any goal valuable, even if the goal is not reached
        ?Is identity something people are born with or given, or is it something people create for themselves?
        Is it best for people to accept who they are and what they have, or should people always strive to better themselves?
        Do success and happiness depend on the choices people make rather than on factors beyond their control?
        Are people more likely to be happy if they focus on goals other than their own happiness?
        Is it more important to do work that one finds fulfilling or work that pays well?
        Do highly accomplished people achieve more than others mainly because they expect more of themselves?
        Can people achieve success only if they aim to be perfect?
        Is it best to have low expectations and to set goals we are sure of achieving?
        Is it necessary for people to combine their efforts with those of others in order to be most effective?
        Are organizations or groups most successful when their members pursue individual wishes and goals?
        Do people achieve more success by cooperation than by competition?
        Does fame bring happiness, or are people who are not famous more likely to be happy?
        Are people's actions motivated primarily by a desire for power over others?
        Do people achieve greatness only by finding out what they are especially good at and developing that attribute above all else?
        Are all important discoveries the result of focusing on one subject?
        Does a strong commitment to technological progress cause a society to neglect other values, such as education and the protection of the environment?
        Are there benefits to be gained from avoiding the use of modern technology, even when using it would make life easier?
        Has today's abundance of information only made it more difficult for us to understand the world around us?
        Is the most important purpose of technology today different from what it was in the past?
        Have modern advancements truly improved the quality of people's lives?
        Do newspapers, magazines, television, radio, movies, the Internet, and other media determine what is important to most people?
        Should modern society be criticized for being materialistic?
        Do we benefit from learning about the flaws of people we admire and respect?
        Should we limit our use of the term "courage" to acts in which people risk their own well-being for the sake of others or to uphold a value?
        Should we admire heroes but not celebrities?
        Is there a value in celebrating certain individuals as heroes?
        Do all established traditions deserve to remain in existence?
        Do people need to "unlearn," or reject, many of their assumptions and ideas?
        Should people always prefer new things, ideas, or values to those of the past?
        Do incidents from the past continue to influence the present?
        Do memories hinder or help people in their effort to learn from the past and succeed in the present?
        Is it always necessary to find new solutions to problems?
        Should people always be loyal?
        Do circumstances determine whether or not we should tell the truth?
        Can deception—pretending that something is true when it is not—sometimes have good results?
        Is it sometimes necessary to be impolite?
        Is acting an essential part of everyday life?
        Is compromise always the best way to resolve a conflict?
        Should people choose one of two opposing sides of an issue, or is the truth usually found "in the middle"?
        Is the main value of the arts to teach us about the world around us?
        Can books and stories about characters and events that are not real teach us anything useful?
        Can common sense be trusted and accepted, or should it be questioned?
        Do people put too much emphasis on learning practical skills?
        Should people take more responsibility for solving problems that affect their communities or the nation in general?
        Should people let their feelings guide them when they make important decisions?
        Can people have too much enthusiasm?
        Do images and impressions have too much of an effect on people?
        Are decisions made quickly just as good as decisions made slowly and carefully?
        Should people change their decisions when circumstances change, or is it best for them to stick with their original decisions?
        Is it better to change one's attitude than to change one's circumstances?
        Is criticism—judging or finding fault with the ideas and actions of others—essential for personal well-being and social progress?
        Does having a large number of options to choose from make people happy?'''.replace("'", "")
    list1 = str1.split('        ')
    return list[random.randomint(list1[0],list1[len(list1)])]


我正在尝试创建一个Python程序,该程序将随机给我一个随笔提示。

最佳答案

将其更改为使用random.choice:另外,您可能希望将标题存储在文本文件中,或者以某种方式将其腌制...

或者只是将它们作为:

titles = [
    'lakjdflasjkfs?',
    'adfasdfssf?',
    'afadff?'
]


样例代码:

from random import choice
def blah():
    str1 = '''your huge list here'''
    titles = str1.splitlines()
    return choice(titles)


也许要代替splitlines()来做

titles = [line.strip() + '?' for line in str1.split('?')]


但是如何拆分取决于您-更好地格式化它!

10-05 21:35