[Solved] How to sum random two numbers?

You need to create a function and then return the output of the addition. A function which takes two arguments. def addition(number1, number2): return number1 + number2 number1 and number2 are the 2 arguments. Since you already have 2 numbers in your list you can pass them like this. print(addition(*randomlist)) The * unpacks the items … Read more

[Solved] Syntax error on if in Python

You need to do it this way, if i am correct to assume this is your purpose: petname = [‘Zophie’, ‘Pooka’, ‘Fat-tail’] print (‘What is your pets name?’) name = input() if name not in petname: print (‘Your pet is not in the list’) else: print (‘Your pet is in the list’) solved Syntax error … Read more

[Solved] Removing duplicates every 5 minutes [closed]

Start from adding DatTim column (of type DateTime), taking source data from Date and Time: df[‘DatTim’] = pd.to_datetime(df.Date + ‘ ‘ + df.Time) Then, assuming that ID is an “ordinary” column (not the index), you should call: groupby on DatTim column with 5 min frequency. To each group apply drop_duplicates, with subset including only ID … Read more

[Solved] List comprehension example I don’t understand [closed]

Your code is using Python’s list comprehension to create a list from another list based on the condition. See more about list comprehensions here: https://www.programiz.com/python-programming/list-comprehension The [1] is accessing the item at index 1 (2nd item) of your sorted list. As for .join, each line in the sorted list is being printed out with a … Read more

[Solved] How to read multiple txt file from a single folder in Python? [duplicate]

Your glob isn’t correct. You should add a /* to the end of your path to select all files (or directories) in your path, and then check if they are files with os.path.isfile. Something like: from os.path import isfile files=filter(isfile,glob.glob(‘%s/*’%path)) You also have an issue with the actual opening. When your with statement ends, the … Read more

[Solved] Create a numeric string using three variables

Thank you i was searching about something like that s=input(‘Enter S’) e=input(‘Enter E’) A=[] for x in range (s,e): A.append(x) if len(A)==3: print(A[0],A[1],A[2]) del A[0:3] Sorry i was not helpful in describe what i want solved Create a numeric string using three variables

[Solved] Get value from JSON in Python [closed]

you can do that as follows: d = {“coord”: {“lon”: -71.06, “lat”: 42.36}, “weather”: [{“id”: 500, “main”: “Rain”, “description”: “light rain”, “icon”: “10n”}], “base”: “stations”, “main”: {“temp”: 1.69, “feels_like”: -1.22, “temp_min”: 0, “temp_max”: 3.33, “pressure”: 1013, “humidity”: 94}, “visibility”: 16093, “wind”: { “speed”: 1.5, “deg”: 230}, “rain”: {“1h”: 0.25}, “clouds”: {“all”: 90}, “dt”: 1582094044, “sys”: … Read more