wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if a = 61 | if a == 61 | Use ==. | Ruby |
val c = 23; c = 54 | var c = 23; c = 54 | Use var for reassignment. | Scala |
{{'id':25, 'age' 20}} | {{'id':25, 'age':20}} | Colon missing. | Python |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if (x = 12) {{}} | if (x == 12) {{}} | Use ==. | Kotlin |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let v=vec![53,13,84]; let head=&v[0]; v.push(95); | let mut v=vec![53,13,84]; let head=v[0]; v.push(95); | Copy instead of reference. | Rust |
$y = 97; if ($y = 97) {{}} | $y = 97; if ($y == 97) {{}} | Use ==. | PHP |
h1 {{ font-size:6px color:green; }} | h1 {{ font-size:6px; color:green; }} | Add semicolon. | CSS |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
disp('result') | disp('result') | Correct. | MATLAB |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
handle | handle() | Add parentheses. | Swift |
String result = 'message'; | String result = "message"; | Double quotes. | Java |
["data", 91] | ["data", 91] | Correct. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
name: output
age: 61 | name: output
age: 61 | Correct. | YAML |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
println('data') | println("data") | Double quotes. | Scala |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
const val = 34; val = 80; | let val = 34; val = 80; | Cannot reassign const. | JavaScript |
h1 {{ font-size:62px color:#fff; }} | h1 {{ font-size:62px; color:#fff; }} | Add semicolon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
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 |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
num = message | num = 'message' | Quote strings. | Python |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
const val; | const val = 19; | Initialize const. | JavaScript |
<person age=89> | <person age="89"> | Quote attribute. | XML |
<br></br> | <br> | Self-closing. | HTML |
if item = 6 then
print('world')
end | if item == 6 then
print('world')
end | Use ==. | Lua |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:58}}; | Add missing property. | TypeScript |
function handle(num:string){{return num;}} handle(57); | function handle(num:string){{return num;}} handle('test'); | Pass correct type. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if (x = 91) {} | if (x == 91) {} | Use ==. | Dart |
jwt.sign({{id:37}}, 'key'); | jwt.sign({{id:37}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
function render(x)
print(x)
end | function render(x)
print(x)
end | Correct. | Lua |
for i=1,39 do print(i) end | for i=1,39 do print(i) end | Correct. | Lua |
item == '37' | item === 37 | Use strict equality. | JavaScript |
var x int | var x int | Correct. | Go |
if num = 58 | if num == 58 | Use ==. | Ruby |
fn bar() -> i32 {{ 18 }} | fn bar() -> i32 {{ 18 }} | Correct. | Rust |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
if (bar = 51) | if (bar == 51) | Use ==. | R |
var x = 13; | var x = 13; | Correct. | Dart |
UPDATE items SET age='info' WHERE status=8 | UPDATE items SET age='info' WHERE status=8; | Add semicolon. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
String count = 'result'; | String count = "result"; | Double quotes. | Java |
'8' + 82 | 8 + 82 | Avoid string coercion. | JavaScript |
val x: Int = 'value' | val x: String = 'value' | Fix type. | Kotlin |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if temp = 65 | if temp == 65 | Use ==. | Go |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
disp('value') | disp('value') | Correct. | MATLAB |
data = 74 | data=74 | No spaces. | Shell |
if num > 95
print('hello') | if num > 95:
print('hello') | Colon missing after if. | Python |
{{'name':88, 'id' 66}} | {{'name':88, 'id':66}} | Colon missing. | Python |
function bar(): void {{ return 44; }} | function bar(): number {{ return 44; }} | Return type mismatch. | TypeScript |
if [ $b = 99 ]; then | if [ "$b" = 99 ]; then | Quote variable. | Shell |
if val = 29 {{}} | if val == 29 {{}} | Use ==. | Swift |
class User {{ int bar; }}
obj.bar=5; | class User {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int z = 'message'; | String z = 'message'; | Type mismatch. | Dart |
list(18) | if length(list) >= 18, list(18), end | Check length. | MATLAB |
handle | handle() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
WHERE status = '55' | WHERE status = 55 | Don't quote integer. | SQL |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for (int i=0; i<84; i++) {{}} | for (int i=0; i<84; i++) {{}} | Correct. | Java |
local bar = 88 | local bar = 88 | Correct. | Lua |
<user><name>message</name><desc>60</desc></user | <user><name>message</name><desc>60</desc></user> | Add closing >. | XML |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
else
print('info') | else:
print('info') | Colon after else. | Python |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
yield c | yield c | Correct yield. | Python |
let index = 'test' | let index = "test" | Double quotes. | Swift |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let y: number = 'world'; | let y: string = 'world'; | Fix type. | TypeScript |
[18, 40, 69 | [18, 40, 69] | Close bracket. | Ruby |
DELETE FROM users WHERE status=63 | DELETE FROM users WHERE status=63; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.