Announcement

Collapse
No announcement yet.

Python Programming Question

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

  • Python Programming Question

    Hi guys,




    Im trying to teach myself python and I am trying to create a program that compares a randomly generated letter to a letter that a user chooses. For some reason though, the program will think that the user's letter(h for example) is equivalent to some random letter like j. I don't know if I'm comparing the functions incorrectly or what, but any help would be much appreciated. Thanks




    import random

    def randomsentence():
    abc = 'abcdefghijklmnopqrstuvwxyz '
    randomstring = str(random.choice(abc))
    return randomstring

    def userstring():
    user = 's'
    return user

    def comparison():
    while userstring() != randomsentence():
    print("There is currently no match")
    if randomsentence() == userstring():
    print(f"There is a match, user generated is {userstring()}, the random generated is {randomsentence()}")
    break
    comparison()
Sorry, you are not authorized to view this page

Home Page

Immigration Daily

Archives

Processing times

Immigration forms

Discussion board

Resources

Blogs

Twitter feed

Immigrant Nation

Attorney2Attorney

CLE Workshops

Immigration books

Advertise on ILW

EB-5

移民日报

About ILW.COM

Connect to us

Questions/Comments

SUBSCRIBE

Immigration Daily



Working...
X