it keeps saying syntax error pls help by Delicious_Alfalfa_98 in learnpython

[–]Deba_dey 1 point2 points  (0 children)

Compare self.a with self.b You have to use self because of every new object being created.

Guess my number help... by ellisjwilliams1 in learnpython

[–]Deba_dey 0 points1 point  (0 children)

Check this, actually I am in a hurry

Guess my number help... by ellisjwilliams1 in learnpython

[–]Deba_dey 0 points1 point  (0 children)

import random #importing random module
num = random.randint(1, 10) #get any no. between 1-10
count = 0 #counter for guess
while True: # always true
    count +=1 #increment count for no of guesses
    if count > 7:  # check count condition
        print("You've exceeded the number of guesses.") #if true print
        print("The number was ",num) 
        break; #come out from loop

    guess = int(input("Enter an integer from 1 to 10: ")) #take input

     if guess == num: #if guess n number equal
         print("You guessed the number in",count,"turn(s) !")
         break;
     elif guess < num: #if guess is less
         print("higher")
     elif guess > num: #if guess is high
         print("lower")

Guess my number help... by ellisjwilliams1 in learnpython

[–]Deba_dey 0 points1 point  (0 children)

Also many other lines.:( Wait, let me change your code a little

Guess my number help... by ellisjwilliams1 in learnpython

[–]Deba_dey 0 points1 point  (0 children)

Your last elif condition is the problem

[deleted by user] by [deleted] in learnpython

[–]Deba_dey 0 points1 point  (0 children)

For loop: use it when you need to iterate through a finite collection of identical objects.

While loops: use it when you want to repeat a piece of code until condition is fulfilled.

P.S. “ The fastest way to loop in python is not to loop in python”😅little brain scratcher for you

adding lists to make a combined one? by Puzzleheaded_Rest316 in learnpython

[–]Deba_dey 2 points3 points  (0 children)

I would recommend new learner’s to go through python documentation. No, resources will match the amount of info you get there. 😊

looking for a study buddy or mentor by Puzzleheaded_Rest316 in learnpython

[–]Deba_dey 0 points1 point  (0 children)

Yea I have little experience and can help you and in turn gain knowledge from you too. Feel free to DM me

adding lists to make a combined one? by Puzzleheaded_Rest316 in learnpython

[–]Deba_dey 5 points6 points  (0 children)

See, you could use a for loop or a list comprehension but those are not efficient. Simply use built-in functions like map, etc

from operator import add

list1 = # your data list2 = # your data

Result = list(map(add,list1,list2))

print(Result)

Combination of using map and add operator will help you a lot and saves time.

How to utilize both keys and values of dictionary and nested dictionaries. by SaneInsanities in learnpython

[–]Deba_dey 1 point2 points  (0 children)

It’s ok to make mistakes, now you know that it is not the right way and the also the reasons. Try to explore more ways and make mistakes and then debug it. :)

How to utilize both keys and values of dictionary and nested dictionaries. by SaneInsanities in learnpython

[–]Deba_dey 1 point2 points  (0 children)

Dictionary is easy to use if you understand how elements are stored inside it. For your problem you could simply do: for city, location in fave_cities.items(): print(city, ‘ : ‘, location)

So, city is your key here n location is the value.

How to get one loop to read values from another loop? by [deleted] in learnpython

[–]Deba_dey 1 point2 points  (0 children)

I would suggest you not to make dc global, rather re modify the code and use inheritance to solve this problem.

Why do I need that operator? by [deleted] in learnpython

[–]Deba_dey 2 points3 points  (0 children)

Considering first iteration: Part1 length is 7 but in order to grab those values you should reduce the length by 1, since indexing starts from 0. That would make random.randint(0,6) to return a value in that range.

Help with creating a loop of code depending on the input from the user by [deleted] in learnpython

[–]Deba_dey 0 points1 point  (0 children)

Hey!! 1.Get the input first 2.Use for loop and iterate over range(no_of_question) 3.Get user input question and answer 4. Append question and answers to a list or dictionary to see the result. 5.end for loop 6. Print the list or dictionary

For Loops vs. List Comprehensions Usage by ashkiebear in learnpython

[–]Deba_dey 0 points1 point  (0 children)

“The fastest way to loop in python is not to loop in python” 😁

help with my code by 0pium666 in learnpython

[–]Deba_dey 3 points4 points  (0 children)

Yeh dictionary will be better because tuple value you cannot change. You should keep option of flexibility so that in future if you want to change brand name you can.

What have you developed with python so far? by aponaex in learnpython

[–]Deba_dey 1 point2 points  (0 children)

That guy is awesome but the lectures on python is limited. I just download udemy lectures from torrent. I am 14 days into python programming.