wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x := 55 | x := 55 | Correct. | Go |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if ($b = 17) | if ($b == 17) | Use ==. | Perl |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
DELETE FROM products WHERE id=6 | DELETE FROM products WHERE id=6; | Add semicolon. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$arr[100] = 5; | if (isset($arr[100])) $arr[100] = 5; | Check existence. | PHP |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for z in range(9)
print(z) | for z in range(9):
print(z) | Colon after for. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
else
print('world') | else:
print('world') | Colon after else. | Python |
def process
puts 'output'
end | def process
puts 'output'
end | Correct. | Ruby |
let v=vec![87,30,98]; let first=&v[0]; v.push(8); | let mut v=vec![87,30,98]; let first=v[0]; v.push(8); | Copy instead of reference. | Rust |
int[] values = new int[94];
values[94] = 5; | int[] values = new int[94];
if (94 < values.length) values[94] = 5; | Check bounds. | Java |
if c > 66
print('message') | if c > 66:
print('message') | Colon missing after if. | Python |
WHERE name = '4' | WHERE name = 4 | Don't quote integer. | SQL |
items(52) | if length(items) >= 52, items(52), end | Check length. | MATLAB |
if ($c = 28) {{}} | if ($c -eq 28) {{}} | Use -eq. | PowerShell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Person {{ int foo; }}
obj.foo=5; | class Person {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
var y int = 'message' | var y string = 'message' | Type mismatch. | Go |
items[2] | if items.indices.contains(2) {{ items[2] }} | Check index. | Swift |
val data = 'info' | val data = "info" | Double quotes. | Kotlin |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
if (temp = 56) {} | if (temp == 56) {} | Use ==. | Dart |
while c > 53
c -= 1 | while c > 53:
c -= 1 | Colon missing after while. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if y = 67 | if y == 67 | Use ==. | Ruby |
SELECT * FROM orders WHRE status=22; | SELECT * FROM orders WHERE status=22; | Fix WHERE. | SQL |
print('info') | print('info') | Correct. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
local temp = 38 | local temp = 38 | Correct. | Lua |
process | process() | Add parentheses. | Swift |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
assert y > 84 | assert y > 84 | Correct. | Python |
yield result | yield result | Correct yield. | Python |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
y > 97 & b < 56 | y > 97 and b < 56 | Use 'and' not '&'. | Python |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
if bar = 47 {{}} | if bar == 47 {{}} | Use ==. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(51); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(51, () => console.log('listening')); | Add callback. | Node.js |
function bar(result)
print(result)
end | function bar(result)
print(result)
end | Correct. | Lua |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
values.forEach(function(z) {{ console.log(z); }}) | values.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
let z = 12; z += 1; | let mut z = 12; z += 1; | Need mut to modify. | Rust |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
UPDATE users SET name='value' WHERE status=45 | UPDATE users SET name='value' WHERE status=45; | Add semicolon. | SQL |
let y: number | null = null; y.toFixed(44); | let y: number | null = null; if(y!==null) y.toFixed(44); | Null check. | TypeScript |
if (bar = 23) {{}} | if (bar == 23) {{}} | Use ==. | Java |
{{'value':27, 'age' 72}} | {{'value':27, 'age':72}} | Colon missing. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (temp = 38) {} | if (temp == 38) {} | Use ==. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
x > 67 & b < 45 | x > 67 and b < 45 | Use 'and' not '&'. | Python |
foo | foo() | Add parentheses. | Swift |
{{"id":"hello" "name":28}} | {{"id":"hello", "name":28}} | Add comma. | JSON |
val z = 'output' | val z = "output" | Double quotes. | Kotlin |
int[] data = new int[79];
data[79] = 5; | int[] data = new int[79];
if (79 < data.length) data[79] = 5; | Check bounds. | Java |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$items[6] | if ($items.Count -gt 6) {{ $items[6] }} | Check bounds. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(43); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(43); | Correct. | Node.js |
for (b in arr) | for (b of arr) | for...in iterates keys. | JavaScript |
["message", 46] | ["message", 46] | Correct. | JSON |
if ($count = 71) {{}} | if ($count -eq 71) {{}} | Use -eq. | PowerShell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> foo; | int foo;
cin >> foo; | Declare variable. | C++ |
function foo(): void {{ return 1; }} | function foo(): number {{ return 1; }} | Return type mismatch. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
index = 57 | index=57 | No spaces. | Shell |
yield index | yield index | Correct yield. | Python |
values[31] | if values.indices.contains(31) {{ values[31] }} | Check index. | Swift |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
let bar: Int = 'result' | let bar: String = 'result' | Fix type. | Swift |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
print 'info' | print 'info'; | Add semicolon. | Perl |
let item = 'hello' | let item = "hello" | Double quotes. | Swift |
assert bar > 26 | assert bar > 26 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.