How Can We Store Two Different Parameters In A Single Array With Python?
I want to store two parameter of a single user in single array. One is user money that he want to save and the time when he saves his money so this two parameter should be store in
Solution 1:
You can use zip()
function which takes iterables (can be zero or more), aggregates them in a tuple, and return it.
user_money_to_save =[100,399,4499]
time_save = [0.1,0.2,3.4]
user_data = list(zip(user_money_to_save, time_save))
print(user_data)
Output
[(100, 0.1), (399, 0.2), (4499,3.4)]
Post a Comment for "How Can We Store Two Different Parameters In A Single Array With Python?"