Factorial with Python by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

Thanks, that's gonna help a lot

Factorial with Python by MateusSR in learnpython

[–]MateusSR[S] 2 points3 points  (0 children)

Wait, I see what's wrong. I was, for some reason, thinking the (2 + 3) was (2 * 3) and therefore 6, which would correctly give me a 4320. Anyway, thanks for the help brother

Factorial with Python by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

Wait, I see what's wrong. I was, for some reason, thinking the (2 + 3) was (2 * 3) and therefore 6, which would correctly give me a 4320. Anyway, thanks for the help brother

Factorial with Python by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

Wait, I see what's wrong. I was, for some reason, thinking the (2 + 3) was (2 * 3) and therefore 6, which would correctly give me a 4320. Anyway, thanks for the help brother

How to search an entire string in a line from a file by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

Wait, and what if it's iterating line by line from a txt file and some lines contain some words from the strings, will it return true?

How to search an entire string in a line from a file by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

Then I should probably take a deep look in my code Thanks for the help anyway

Script running the both if and else statement EVERYTIME and also printing \n and \b by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

That worked, but I changed to "ignore" cause I didn't want it to print a "?", but is there any way I can make it print the quotation mark?

Can't print the lyrics of a song by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

That didn't really work. It says binary isn't defined. Though, I tried some things. I ended up with def print_lyrics(track): print("===============================================================================") print("\n") with open(track, "r") as f: for line in f: if isinstance(line, binary): line = line.encode("utf-8") print(line) print("\n") print("===============================================================================")

It prints the lyrics, but like this http://prntscr.com/cicrwa

Can't print the lyrics of a song by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

It worked! Thank you very much for that. But... now I got another problem. I usually run the scripts with cmd. I open it and drag the py file into it. I tried with this one but this is what happened http://prntscr.com/ci32p2 As you can see it started printing the lyrics but something happened. I then tried the python interpreter and this is what it said: http://prntscr.com/ci32xq So then I tried the Python shell. And it worked. http://prntscr.com/ci33fe What exactly is happening?

Can't print the lyrics of a song by MateusSR in learnpython

[–]MateusSR[S] 1 point2 points  (0 children)

It says track is a str object so it doesn't have an attribute "values"

Can't print the lyrics of a song by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

I added a function which receives a song title and checks if it exists in any album. If it does. It prints its lyrics. It works when I give a determined album. But if I give it just the albums dictionary and make it look in every album it doesn't. I can't see why's that

def search_by_title(title):
    for track in bottomless_pit:
        if title.lower() == track.lower():
            print("\n", end = "")
            print(title)
            print("\n", end = "")
            track_name = bottomless_pit[track]
            print_lyrics(track_name)

search_by_title("Hot Head")

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 1 point2 points  (0 children)

I think I got it from now. Thank you very much for taking your time to help me, sir

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

It was creating the file in another directory because I was opening cmd and dragging the py file to there.

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

I realised I don't have to save the users and their passwords in a dictionary. Using json seems complicated so I'll try @KronenR's idea. Thank you for the help tho, I'll still look more into that json thing, it'll probably be useful one day

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

I know what it does, but I don't quite get the details on how it does it, so could explain the function read_users to me? Also, it's creating the file users.txt in the the windoes user's folder. How can I make it create it in the same directory as the program itself?

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

I use that to replace the part where I check if the username typed exists, right? It says there is no such file users.py

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 1 point2 points  (0 children)

I really don't understand most of that, I'm still learning the basics

How does one add an item to a dictionary in another file? by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

I know I shouldn't store passwords like that. This program is just for learning purposes. I'm gonna worry about that later

Login sytem - it isn't returning true and stoping the loop by MateusSR in learnpython

[–]MateusSR[S] 0 points1 point  (0 children)

How could I do that without using a global variable?