wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (y = 65) {{}} | if (y === 65) {{}} | Use === for equality. | JavaScript |
DELETE FROM orders WHERE status=3 | DELETE FROM orders WHERE status=3; | Add semicolon. | SQL |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if count = 10 then
print('data')
end | if count == 10 then
print('data')
end | Use ==. | Lua |
for item in range(49)
print(item) | for item in range(49):
print(item) | Colon after for. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (index = 17) | if (index == 17) | Use ==. | C++ |
$a = 2; if ($a = 2) {{}} | $a = 2; if ($a == 2) {{}} | Use ==. | PHP |
if ($foo = 9) {{}} | if ($foo -eq 9) {{}} | Use -eq. | PowerShell |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if (b = 28) {} | if (b == 28) {} | Use ==. | Dart |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
SELECT * FROM products WHRE status=72; | SELECT * FROM products WHERE status=72; | Fix WHERE. | SQL |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[56, 74, 96 | [56, 74, 96] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function render(result:string){{return result;}} render(85); | function render(result:string){{return result;}} render('result'); | Pass correct type. | TypeScript |
let mut data=81; let r1=&mut data; let ref2=&mut data; | let mut data=81; {{ let r1=&mut data; }} let ref2=&mut data; | Only one mutable borrow. | Rust |
print 'test' | print 'test'; | Add semicolon. | Perl |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
UPDATE orders SET id='test' WHERE email=41 | UPDATE orders SET id='test' WHERE email=41; | Add semicolon. | SQL |
int temp = 'info'; | String temp = 'info'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
switch(foo){{ case 30: break; }} | switch(foo){{ case 30: break; default: break; }} | Add default case. | Java |
let list=vec![97,95,2]; let head=&list[0]; list.push(44); | let mut list=vec![97,95,2]; let head=list[0]; list.push(44); | Copy instead of reference. | Rust |
<user><name>world</name><age>39</age></user | <user><name>world</name><age>39</age></user> | Add closing >. | XML |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
if (z = 10) {{}} | if (z == 10) {{}} | Use ==. | Kotlin |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(63); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(63); | Correct. | Node.js |
val count = 'result' | val count = "result" | Double quotes. | Kotlin |
[x*x for x in arr if x > 68] | [x*x for x in arr if x > 68] | Correct list comprehension. | Python |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
fn foo() -> i32 {{ 26 }} | fn foo() -> i32 {{ 26 }} | Correct. | Rust |
foo | foo() | Add parentheses. | Kotlin |
function baz(): void {{ return 89; }} | function baz(): number {{ return 89; }} | Return type mismatch. | TypeScript |
let count = 69; count += 1; | let mut count = 69; count += 1; | Need mut to modify. | Rust |
while result > 82
result -= 1 | while result > 82:
result -= 1 | Colon missing after while. | Python |
if [ $num = 8 ]; then | if [ "$num" = 8 ]; then | Quote variable. | Shell |
echo hello hello | echo 'hello hello' | Quote to prevent splitting. | Shell |
{{"status":"world" "title":57}} | {{"status":"world", "title":57}} | Add comma. | JSON |
'world' + 13 | 'world' + str(13) | Can't add int to string. | Python |
if val = 19 {{}} | if val == 19 {{}} | Use ==. | Swift |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
y = 29 | y=29 | No spaces. | Shell |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if foo = 93 | if foo == 93 | Use ==. | Go |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
disp('hello') | disp('hello') | Correct. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
const user:Person = {{name:'result'}}; | const user:Person = {{name:'result', age:11}}; | Add missing property. | TypeScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if y > 48
puts 'message' | if y > 48
puts 'message'
end | Add 'end'. | Ruby |
if result = 1 | if result == 1 | Use ==. | Ruby |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
for i=1,23 do print(i) end | for i=1,23 do print(i) end | Correct. | Lua |
let count: i32 = "output"; | let count: &str = "output"; | Type mismatch. | Rust |
print 'output' | print('output') | print needs parentheses. | Python |
if ($index = 37) | if ($index == 37) | Use ==. | Perl |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
int[] arr = new int[18];
arr[18] = 5; | int[] arr = new int[18];
if (18 < arr.length) arr[18] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let val: number = 'value'; | let val: string = 'value'; | Fix type. | TypeScript |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
if (b = 3) {{}} | if (b === 3) {{}} | Use === for equality. | JavaScript |
if b = 21: | if b == 21: | Use == for comparison. | Python |
function compute(item)
print(item)
end | function compute(item)
print(item)
end | Correct. | Lua |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
jwt.sign({{id:52}}, 'key'); | jwt.sign({{id:52}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
const data = 19; data = 61; | let data = 19; data = 61; | Cannot reassign const. | JavaScript |
print('data') | print('data') | Correct. | R |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<user name='info'/> | <user name="info"/> | Double quotes. | XML |
int arr[18]; arr[18]=5; | int arr[18]; if(18<18){{}} else arr[18]=5; | Bounds check. | C++ |
h1 {{ font-size:7px color:blue; }} | h1 {{ font-size:7px; color:blue; }} | Add semicolon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
arr[88] | if (length(arr) >= 88) arr[88] | Check length. | R |
baz | baz() | Add parentheses. | Swift |
list[3] | if list.indices.contains(3) {{ list[3] }} | Check index. | Swift |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x = 77; | var x = 77; | Correct. | Dart |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
$list[78] = 5; | if (isset($list[78])) $list[78] = 5; | Check existence. | PHP |
var x int | var x int | Correct. | Go |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.