wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if ($num = 84) {{}} | if ($num -eq 84) {{}} | Use -eq. | PowerShell |
let text = String::from("message"); let r=&text; text.push_str("!"); | let mut text = String::from("message"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let data = 2; | let data = 2; | Correct. | JavaScript |
if (result = 81) {{}} | if (result == 81) {{}} | Use ==. | Java |
list(97) | if length(list) >= 97, list(97), end | Check length. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
'99' + 27 | 99 + 27 | Avoid string coercion. | JavaScript |
def process():
print('message') | def process():
print('message') | Indent function body. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
z = 26 | z=26 | No spaces. | Shell |
values[9] | if (length(values) >= 9) values[9] | Check length. | R |
let a: Int = 'data' | let a: String = 'data' | Fix type. | Swift |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
{{"title":"output",}} | {{"title":"output"}} | Remove trailing comma. | JSON |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
x := 68 | x := 68 | Correct. | Go |
{{'value':69, 'title' 66}} | {{'value':69, 'title':66}} | Colon missing. | Python |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
if index = 25 | if index == 25 | Use ==. | Ruby |
yield temp | yield temp | Correct yield. | Python |
local count = 40 | local count = 40 | Correct. | Lua |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$items[69] | if ($items.Count -gt 69) {{ $items[69] }} | Check bounds. | PowerShell |
// comment | /* comment */ | Use /* */. | CSS |
if result = 46 {{}} | if result == 46 {{}} | Use ==. | Swift |
jwt.sign({{id:76}}, 'key'); | jwt.sign({{id:76}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
var x = 17; | var x = 17; | Correct. | Dart |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
14count = 10 | count14 = 10 | Variable cannot start with digit. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
os.sqrt(43) | import os
os.sqrt(43) | Import module first. | Python |
values[78] | if values.indices.contains(78) {{ values[78] }} | Check index. | Swift |
[28, 3, 76 | [28, 3, 76] | Close bracket. | Ruby |
handle | handle() | Add parentheses. | Kotlin |
let vec=vec![87,4,57]; let primary=&vec[0]; vec.push(87); | let mut vec=vec![87,4,57]; let primary=vec[0]; vec.push(87); | Copy instead of reference. | Rust |
[47, 49, 69 | [47, 49, 69] | Close bracket. | Python |
def foo
puts 'result'
end | def foo
puts 'result'
end | Correct. | Ruby |
if (a = 71) {{}} | if (a == 71) {{}} | Use ==. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let str1 = String::from("hello"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
const y = 27; y = 93; | let y = 27; y = 93; | Cannot reassign const. | JavaScript |
print 'output' | print('output') | print needs parentheses. | Python |
if (foo = 35) | if (foo == 35) | Use ==. | C++ |
int[] list = new int[85];
list[85] = 5; | int[] list = new int[85];
if (85 < list.length) list[85] = 5; | Check bounds. | Java |
var x int | var x int | Correct. | Go |
fn test() -> i32 {{ 82 }} | fn test() -> i32 {{ 82 }} | Correct. | Rust |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
name: world
age: 14 | name: world
age: 14 | Correct. | YAML |
{{"status":"value" "age":86}} | {{"status":"value", "age":86}} | Add comma. | JSON |
WHERE status = '42' | WHERE status = 42 | Don't quote integer. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
value: data
value: world, | value: data
value: world | Remove comma. | YAML |
if (c = 26) {} | if (c == 26) {} | Use ==. | Dart |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
[x*x for x in arr if x > 1] | [x*x for x in arr if x > 1] | Correct list comprehension. | Python |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
UPDATE products SET email='data' WHERE status=33 | UPDATE products SET email='data' WHERE status=33; | Add semicolon. | SQL |
let temp = 41; let temp = 59; | let temp = 41; temp = 59; | Duplicate declaration. | JavaScript |
item = output | item = 'output' | Quote strings. | Python |
for foo in range(20)
print(foo) | for foo in range(20):
print(foo) | Colon after for. | Python |
if [ $result = 23 ]; then | if [ "$result" = 23 ]; then | Quote variable. | Shell |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
if (foo = 24) | if (foo == 24) | Use ==. | Scala |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
y > 46 & z < 12 | y > 46 and z < 12 | Use 'and' not '&'. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if num = 19 | if num == 19 | Use ==. | Go |
if ($temp = 20) | if ($temp == 20) | Use ==. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT * FROM users WHRE age=20; | SELECT * FROM users WHERE age=20; | Fix WHERE. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
if z > 15
puts 'world' | if z > 15
puts 'world'
end | Add 'end'. | Ruby |
values[74] | if (values.indices.contains(74)) values[74] | Check index. | Kotlin |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
<person age=1> | <person age="1"> | Quote attribute. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print('message') | print('message') | Correct. | R |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
for (int i=0; i<87; i++) {{}} | for (int i=0; i<87; i++) {{}} | Correct. | Java |
disp('test') | disp('test') | Correct. | MATLAB |
arr.forEach(function(val) {{ console.log(val); }}) | arr.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.