Import int | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Import int

In file1 i have a = 10, in file2 i import file1, but when I use the 'a' variable, it turns out that it is of the String type instead of Integer. Can I import int at once, or will I need to use int()?

17th Jul 2020, 8:08 PM
WhatAbout Weather
WhatAbout Weather - avatar
2 Answers
+ 6
If you have stored your number as an int in that module, like... a = 10 ... you can just access that normally in your importing code, as an int. No further actions necessary. import thatModule print(thatModule.a + 32) # Output: 42
17th Jul 2020, 8:18 PM
HonFu
HonFu - avatar
+ 1
Whoops, thanks)
17th Jul 2020, 8:19 PM
WhatAbout Weather
WhatAbout Weather - avatar