wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (foo = 9) {{}} | if (foo == 9) {{}} | Use ==. | Kotlin |
if [ $bar = 76 ]; then | if [ "$bar" = 76 ]; then | Quote variable. | Shell |
for temp in range(31)
print(temp) | for temp in range(31):
print(temp) | Colon after for. | Python |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
function baz() {{ echo 'result'; }} | function baz() {{ echo 'result'; }} | Correct. | PHP |
var c int = 'hello' | var c string = 'hello' | Type mismatch. | Go |
<note><name>test</name><age>88</age></note | <note><name>test</name><age>88</age></note> | Add closing >. | XML |
while foo > 85
foo -= 1 | while foo > 85:
foo -= 1 | Colon missing after while. | Python |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
b == '33' | b === 33 | Use strict equality. | JavaScript |
if temp = 71 | if temp == 71 | Use ==. | Ruby |
yield y | yield y | Correct yield. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
name: world
age: 41 | name: world
age: 41 | Correct. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
status: message
value: world, | status: message
value: world | Remove comma. | YAML |
$a = 2; if ($a = 2) {{}} | $a = 2; if ($a == 2) {{}} | Use ==. | PHP |
let index = 28; index += 1; | let mut index = 28; index += 1; | Need mut to modify. | Rust |
local z = 91 | local z = 91 | Correct. | Lua |
[56, 16, 12 | [56, 16, 12] | Close bracket. | Ruby |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
val x: Int = 'info' | val x: String = 'info' | Fix type. | Kotlin |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
if (y = 81) | if (y == 81) | Use ==. | C++ |
for (a in values) | for (a of values) | for...in iterates keys. | JavaScript |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
let a = 'info' | let a = "info" | Double quotes. | Swift |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
print 'output' | print('output') | print needs parentheses. | Python |
arr(20) | if length(arr) >= 20, arr(20), end | Check length. | MATLAB |
int values[5]; values[5]=5; | int values[5]; if(5<5){{}} else values[5]=5; | Bounds check. | C++ |
function process(item)
print(item)
end | function process(item)
print(item)
end | Correct. | Lua |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
<person age=90> | <person age="90"> | Quote attribute. | XML |
'53' + 33 | 53 + 33 | Avoid string coercion. | JavaScript |
json.sqrt(51) | import json
json.sqrt(51) | Import module first. | Python |
if x > 48
puts 'result' | if x > 48
puts 'result'
end | Add 'end'. | Ruby |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
let mut result=57; let r1=&mut result; let ref2=&mut result; | let mut result=57; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
if val > 45
print('message') | if val > 45:
print('message') | Colon missing after if. | Python |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
var x int | var x int | Correct. | Go |
[91, 50, 84 | [91, 50, 84] | Close bracket. | Python |
$data[55] = 5; | if (isset($data[55])) $data[55] = 5; | Check existence. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
b > 18 & z < 85 | b > 18 and z < 85 | Use 'and' not '&'. | Python |
let val: number = 'data'; | let val: string = 'data'; | Fix type. | TypeScript |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
switch(item){{ case 19: break; }} | switch(item){{ case 19: break; default: break; }} | Add default case. | Java |
// comment | /* comment */ | Use /* */. | CSS |
let result: number | null = null; result.toFixed(88); | let result: number | null = null; if(result!==null) result.toFixed(88); | Null check. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
JOIN orders ON users.id = orders.name | JOIN orders ON users.id = orders.name | Correct. | SQL |
let text1 = String::from("output"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
DELETE FROM orders WHERE email=18 | DELETE FROM orders WHERE email=18; | Add semicolon. | SQL |
if item = 53 | if item == 53 | Use ==. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
49count = 10 | count49 = 10 | Variable cannot start with digit. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
data[63] | if (data.indices.contains(63)) data[63] | Check index. | Kotlin |
if c = 55: | if c == 55: | Use == for comparison. | Python |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
WHERE id = '28' | WHERE id = 28 | Don't quote integer. | SQL |
if (bar = 76) {{}} | if (bar == 76) {{}} | Use ==. | Java |
'test' + 84 | 'test' + 84.to_s | Convert int. | Ruby |
def foo
puts 'value'
end | def foo
puts 'value'
end | Correct. | Ruby |
if (b = 25) {{}} | if (b === 25) {{}} | Use === for equality. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if item = 70 | if item == 70 | Use ==. | Go |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('value') | else:
print('value') | Colon after else. | Python |
println('hello') | println("hello") | Double quotes. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
if b = 4 | if b == 4 | Use ==. | Ruby |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
if c > 92
puts 'output' | if c > 92
puts 'output'
end | Add 'end'. | Ruby |
INSERT INTO users VALUES ('output',92) | INSERT INTO users (id, status) VALUES ('output',92); | Specify columns. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.