Message from Python discussions
November 2018
— None is None
is True
>>> def get_id(id):
... if id < 10:
... return id
... else:
... return None
...
>>> get_id(5)
5
>>> get_id(20)
>>> if get_id(20) is None:
... print("None")
None
— So i should return data = None?
— Help me.
Given an integer N and letter C. Print the string of length N containing only C's.
5,A
— You can just assign your function to a variable name
— Read the rules
— And use it in your if statement
— It will then use the out put of the first return executed in your function
— This is my code.. data = get_user_fm(user_id) from aboveif data is None:
message.reply_text('Please connect your LastFm account')
if not now_playing:
for i in last_played:
buttons = InlineKeyboardMarkup([[InlineKeyboardButton('YouTube',
url='www.youtube.com/results?search_query=' + str(i.track))]])
message.reply_text(first_name + " was listening to \n" + str(i.track), reply_markup=buttons)
else:
buttons = InlineKeyboardMarkup([[InlineKeyboardButton('YouTube',
url='www.youtube.com/results?search_query=' + str(now_playing))]])
message.reply_text(first_name + " is listening to \n" + str(now_playing), reply_markup=buttons)
— Find the letter
— I still don't know how to do that in a nice looking way
— I could return False but i don't think it makes sense