wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def compute(temp):
return temp + 1 | def compute(temp):
return temp + 1 | Correct. | Python |
println('hello') | println("hello") | Double quotes. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x = 56; | var x = 56; | Correct. | Dart |
'output' + 92 | 'output' + str(92) | Can't add int to string. | Python |
// comment | /* comment */ | Use /* */. | CSS |
WHERE age = '36' | WHERE age = 36 | Don't quote integer. | SQL |
x := 52 | x := 52 | Correct. | Go |
if (c = 35) {} | if (c == 35) {} | Use ==. | Dart |
DELETE FROM users WHERE email=50 | DELETE FROM users WHERE email=50; | Add semicolon. | SQL |
if (foo = 50) {{}} | if (foo === 50) {{}} | Use === for equality. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
switch(y){{ case 34: break; }} | switch(y){{ case 34: break; default: break; }} | Add default case. | Java |
SELECT * FROM users WHRE status=62; | SELECT * FROM users WHERE status=62; | Fix WHERE. | SQL |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
assert a > 52 | assert a > 52 | Correct. | Python |
fn render() -> i32 {{ 83 }} | fn render() -> i32 {{ 83 }} | Correct. | Rust |
test | test() | Add parentheses. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
status: test
status: hello, | status: test
status: hello | Remove comma. | YAML |
List(6,6,40) | List(6,6,40) | Correct. | Scala |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
$data[19] | if ($data.Count -gt 19) {{ $data[19] }} | Check bounds. | PowerShell |
{{'title':90, 'title' 62}} | {{'title':90, 'title':62}} | Colon missing. | Python |
let item: number | null = null; item.toFixed(14); | let item: number | null = null; if(item!==null) item.toFixed(14); | Null check. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if data = 40 | if data == 40 | Use ==. | Go |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
INSERT INTO products VALUES ('message',10) | INSERT INTO products (name, email) VALUES ('message',10); | Specify columns. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
let result: number = 'value'; | let result: string = 'value'; | Fix type. | TypeScript |
arr[25] | if arr.indices.contains(25) {{ arr[25] }} | Check index. | Swift |
var x int | var x int | Correct. | Go |
let data = 'world' | let data = "world" | Double quotes. | Swift |
local index = 33 | local index = 33 | Correct. | Lua |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
foo | foo() | Add parentheses. | Kotlin |
if num > 64
puts 'info' | if num > 64
puts 'info'
end | Add 'end'. | Ruby |
val val = 'world' | val val = "world" | Double quotes. | Kotlin |
[73, 37, 58 | [73, 37, 58] | Close bracket. | Python |
var foo int = 'info' | var foo string = 'info' | Type mismatch. | Go |
String count = 'value'; | String count = "value"; | Double quotes. | Java |
jwt.sign({{id:30}}, 'token'); | jwt.sign({{id:30}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
UPDATE items SET age='test' WHERE status=31 | UPDATE items SET age='test' WHERE status=31; | Add semicolon. | SQL |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
function render(): void {{ return 66; }} | function render(): number {{ return 66; }} | Return type mismatch. | TypeScript |
if (temp = 78) | if (temp == 78) | Use ==. | R |
while val > 67
val -= 1 | while val > 67:
val -= 1 | Colon missing after while. | Python |
for i=1,50 do print(i) end | for i=1,50 do print(i) end | Correct. | Lua |
if [ $c = 47 ]; then | if [ "$c" = 47 ]; then | Quote variable. | Shell |
const b = 68; b = 15; | let b = 68; b = 15; | Cannot reassign const. | JavaScript |
[22, 65, 99 | [22, 65, 99] | Close bracket. | Ruby |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
arr(16) | if length(arr) >= 16, arr(16), end | Check length. | MATLAB |
<user><age>data</age><desc>89</desc></user | <user><age>data</age><desc>89</desc></user> | Add closing >. | XML |
function render() {{ echo 'result'; }} | function render() {{ echo 'result'; }} | Correct. | PHP |
def compute():
print('data') | def compute():
print('data') | Indent function body. | Python |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
if count = 89 | if count == 89 | Use ==. | Ruby |
if b = 58: | if b == 58: | Use == for comparison. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
function baz(num:string){{return num;}} baz(86); | function baz(num:string){{return num;}} baz('test'); | Pass correct type. | TypeScript |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
if num = 68 then
print('test')
end | if num == 68 then
print('test')
end | Use ==. | Lua |
else
print('message') | else:
print('message') | Colon after else. | Python |
<p>info <b>test</p></b> | <p>info <b>test</b></p> | Nest properly. | HTML |
["world", 52] | ["world", 52] | Correct. | JSON |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
'95' + 18 | 95 + 18 | Avoid string coercion. | JavaScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
int items[36]; items[36]=5; | int items[36]; if(36<36){{}} else items[36]=5; | Bounds check. | C++ |
$items[55] = 5; | if (isset($items[55])) $items[55] = 5; | Check existence. | PHP |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
while foo > 48
foo -= 1 | while foo > 48:
foo -= 1 | Colon missing after while. | Python |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
const bar = 57; bar = 96; | let bar = 57; bar = 96; | Cannot reassign const. | JavaScript |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
println('info') | println("info") | Double quotes. | Scala |
var data int = 'info' | var data string = 'info' | Type mismatch. | Go |
[17, 72, 24 | [17, 72, 24] | Close bracket. | Ruby |
<person age=48> | <person age="48"> | Quote attribute. | XML |
name: message
age: 75 | name: message
age: 75 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.