Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 373 characters in body
Source Link
Moses Koledoye
  • 78.8k
  • 8
  • 139
  • 141

int does not cast its parameters to integer in-place. In fact those parameters are immutable.

int(sessions) does not exactly do what you think it does. session is not modified, but the return value of that call is an int.

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

The operator >= can now compare the two variables you have, since they are now both integers.


You may also want to rewrite that if block like so:

if data_type == 'sessions': for page, sessions in ga_session_data.items(): if sessions >= int(num): print(page, ' - ', sessions) 

In this way, you're actually checking the sessions count in the dictionary and not the sessions from the for loop.

int does not cast its parameters to integer in-place. In fact those parameters are immutable.

int(sessions) does not exactly do what you think it does. session is not modified, but the return value of that call is an int.

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

The operator >= can now compare the two variables you have, since they are now both integers.

int does not cast its parameters to integer in-place. In fact those parameters are immutable.

int(sessions) does not exactly do what you think it does. session is not modified, but the return value of that call is an int.

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

The operator >= can now compare the two variables you have, since they are now both integers.


You may also want to rewrite that if block like so:

if data_type == 'sessions': for page, sessions in ga_session_data.items(): if sessions >= int(num): print(page, ' - ', sessions) 

In this way, you're actually checking the sessions count in the dictionary and not the sessions from the for loop.

added 4 characters in body
Source Link
Moses Koledoye
  • 78.8k
  • 8
  • 139
  • 141

int does not cast its parameters to integer in-place. In fact those parameters are immutable:.

int(sessions) 

int(sessions) does not exactly do what you think it does. session is not modified, but the return value of that call is an int.

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

The operator >= can now compare the two variables you have, since they are now both integers.

int does not cast its parameters to integer in-place. In fact those parameters are immutable:

int(sessions) 

does not do what you think it does. session is not modified, but the return value of that call is an int

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

int does not cast its parameters to integer in-place. In fact those parameters are immutable.

int(sessions) does not exactly do what you think it does. session is not modified, but the return value of that call is an int.

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews) 

The operator >= can now compare the two variables you have, since they are now both integers.

Source Link
Moses Koledoye
  • 78.8k
  • 8
  • 139
  • 141

int does not cast its parameters to integer in-place. In fact those parameters are immutable:

int(sessions) 

does not do what you think it does. session is not modified, but the return value of that call is an int

You should assign the returned value to a new/same name:

sessions = int(sessions) pageviews = int(pageviews)