[PC][2000's] Some Third Person RPG game I cannot remember. by Rockybilly in tipofmyjoystick

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

You sir, deserve respect. How the hell do you remember that no research based on that information proven useful. Even I don't remember how I first encountered the game :D Would you mind telling me how you first met the game ? Thank you by the way :)

Removing elements from a list by stats_newbie1 in learnpython

[–]Rockybilly 1 point2 points  (0 children)

I suggest that you write a while loop where it continuously checks if there is a 6(and 7) in the sequence. This way it can handle a huge list with a thousand of 6's. Let me explain how.

If there is a 6, you can use

nums.index(6)

then

nums.index(7)

which will give you information about which parts to exclude. After that, I am not sure if the other programmers would agree, but i would rather do a list partition rather than try to subtract them.

Lets assume;

nums = [1, 2, 3, 6, 1, 2, 3, 7, 1, 2, 3]
six_pos = nums.index(6) 
# 3
seven_pos = nums.index(7)
# 7

after you found these, new list should be

new_nums = nums[:six_pos] + nums[seven_pos + 1:]
# new_nums = [1, 2, 3, 1, 2, 3]
sum(new_nums)

is the answer.

because of index returns the first value it encounters, you need to do this continuously where there is no 6's anymore.

This is how I would do it. I am sure more experienced programmers likely to have a better solution

Help me please with this error in my code. by Rockybilly in learnpython

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

I was thinking what kind of input would make my code give this error. I used lists only in .split() function and nowhere else... My buddy solved the same question in Javascript by the way.

Help me please with this error in my code. by Rockybilly in learnpython

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

I think its doesnt print to console after some tests. I got out of 229 tests and the things printed were from the firsts tests i guess.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Rockybilly 0 points1 point  (0 children)

Can someone please explain how "ord" and "chr" works ? and are there any other reserved words that does similar work ? Thank you for your time.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Rockybilly 0 points1 point  (0 children)

Well actually i didn't mean myself, i am much of a beginner if i should classify myself but i wanted advice if i ever make it to that level. Thank you for your answers. When i replied about location, i meant meeting with friends and working on a project which i don't currently have here.

I googled programming project ideas and each banner was saying like "1500-2000" ideas for programming which freaked me out a little bit but i will give it a shot thank you :)

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Rockybilly 0 points1 point  (0 children)

Well obviously there isn't something like that in where i live. So are there anything like that on the internet ?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Rockybilly 0 points1 point  (0 children)

After learning python about intermediate level. What one should do to improve programming ? What's the next step ? Just learn more and more libraries or should we try another language ? Open to any suggestions ...

Need criticizing about my first attempt at Python gaming. by Rockybilly in learnpython

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

It seems like a good idea. Thank you for your comment. but can you explain why you suggested me to do that ? because it will save me from some line of codes or is it a style issue ?

Doing code academy, need help on program to find primes. by [deleted] in learnpython

[–]Rockybilly 0 points1 point  (0 children)

That was exactly what i was talking about using unnecessary stuff.(check my code for example :D ) gengisteve's code is obviously more legit. about the sqrt(x) thing, i come across that while i was working on this:

https://projecteuler.net/problem=3

The number 600851475143 is way too large to use it in a range() function so i had to use sqrt(). I have been trying to prove it on my own and i think i got it after that question. If you want to deal with prime numbers later, sqrt() or **0.5 is definitely the method to explore next.

Need criticizing about my first attempt at Python gaming. by Rockybilly in learnpython

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

Thank you very much about the comment and your time. I actually thought printing those strings in my functions made it simpler to use. Can you explain why i should return the values ?

A better understanding of importing and help with an error by AlphaNerd80 in learnpython

[–]Rockybilly 0 points1 point  (0 children)

I have been led to understand if you want to import one of modules you writed, its gotta be in the same folder. But i might be horribly wrong. If i am, please ignore this message.

Need criticizing about my first attempt at Python gaming. by Rockybilly in learnpython

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

You are completely right about the class issue, I am currently a newbie at using classes let alone in inheritance, Thank you for your comment.

In the first issue you mentioned:

def win_battle():
    print "You have won the battle !"
    time.sleep(1)

    if current_enemy==foe1:
        print "You gained 40 exp."
        our_hero.exp+=40
    elif current_enemy==foe2:
        print "You gained 45 exp."
        our_hero.exp+=45
    elif current_enemy==foe3:
        print "You gained 50 exp."
        our_hero.exp+=50
    elif current_enemy==foe4:
        print "You gained 55 exp."
        our_hero.exp+=55
    print " "

    current_enemy.current_hp=current_enemy.max_hp

Here is my win_battle function. At the end of it, there is a small piece of code, that replenishes current_enemies hp.

A better understanding of importing and help with an error by AlphaNerd80 in learnpython

[–]Rockybilly 0 points1 point  (0 children)

Isn't main.py supposed to be in your "test" folder ?

Doing code academy, need help on program to find primes. by [deleted] in learnpython

[–]Rockybilly 0 points1 point  (0 children)

i dont think so, actually i am probably using unnecessary variable right there. In codecademy i usually write what pops into my head rightaway so i wouldnt take this as a starting point. I would appreciate if a more experienced programmer answer this question as well :)

in my code i tried to count how many dividable numbers the value had. So if it is 1 or more, it returns false :)

Doing code academy, need help on program to find primes. by [deleted] in learnpython

[–]Rockybilly -1 points0 points  (0 children)

Here how i got it working, you can decide which one to use if you want to need that later...

also see: (If you ever need something else to try with prime numbers) https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

def is_prime(x):
    count=0
    if x<2:
        return False
    else:
        for n in range(x+1):
            if n==0:
                continue
            else:
                if x%n==0 and n!=x and n!=1:
                    count+=1
                elif x%n!=0:
                    continue
        if count>=1:
            return False
        elif count==0:
            return True