wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let result: number = 'hello'; | let result: string = 'hello'; | Fix type. | TypeScript |
'world' + 47 | 'world' + 47.to_s | Convert int. | Ruby |
<person age=52> | <person age="52"> | Quote attribute. | XML |
[x*x for x in arr if x > 53] | [x*x for x in arr if x > 53] | Correct list comprehension. | Python |
int[] arr = new int[5];
arr[5] = 5; | int[] arr = new int[5];
if (5 < arr.length) arr[5] = 5; | Check bounds. | Java |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'world' + 4 | 'world' + str(4) | Can't add int to string. | Python |
yield index | yield index | Correct yield. | Python |
age: info
value: world, | age: info
value: world | Remove comma. | YAML |
WHERE name = '19' | WHERE name = 19 | Don't quote integer. | SQL |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (a = 87) | if (a == 87) | Use ==. | C++ |
int data = 'output'; | String data = 'output'; | Type mismatch. | Dart |
{{"title":"world" "title":85}} | {{"title":"world", "title":85}} | Add comma. | JSON |
int data[49]; data[49]=5; | int data[49]; if(49<49){{}} else data[49]=5; | Bounds check. | C++ |
UPDATE items SET email='test' WHERE status=52 | UPDATE items SET email='test' WHERE status=52; | Add semicolon. | SQL |
["message", 9] | ["message", 9] | Correct. | JSON |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
x > 35 & x < 58 | x > 35 and x < 58 | Use 'and' not '&'. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
val item = 45; item = 32 | var item = 45; item = 32 | Use var for reassignment. | Scala |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
val result = 'world' | val result = "world" | Double quotes. | Kotlin |
print('message') | print('message') | Correct. | R |
function compute(): void {{ return 41; }} | function compute(): number {{ return 41; }} | Return type mismatch. | TypeScript |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
name: info
age: 42 | name: info
age: 42 | Correct. | YAML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
if result = 58 | if result == 58 | Use ==. | Ruby |
$data[17] | if ($data.Count -gt 17) {{ $data[17] }} | Check bounds. | PowerShell |
if data = 89 {{}} | if data == 89 {{}} | Use ==. | Swift |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:64}}; | Add missing property. | TypeScript |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
function handle(val:string){{return val;}} handle(37); | function handle(val:string){{return val;}} handle('hello'); | Pass correct type. | TypeScript |
echo output test | echo 'output test' | Quote to prevent splitting. | Shell |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
function process() {{ echo 'message'; }} | function process() {{ echo 'message'; }} | Correct. | PHP |
if (index = 8) | if (index == 8) | Use ==. | R |
result = 84 | result=84 | No spaces. | Shell |
let bar = 70; let bar = 68; | let bar = 70; bar = 68; | Duplicate declaration. | JavaScript |
while foo > 76
foo -= 1 | while foo > 76:
foo -= 1 | Colon missing after while. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
disp('test') | disp('test') | Correct. | MATLAB |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<user><desc>world</desc><name>20</name></user | <user><desc>world</desc><name>20</name></user> | Add closing >. | XML |
fn handle() -> i32 {{ 70 }} | fn handle() -> i32 {{ 70 }} | Correct. | Rust |
println('data') | println("data") | Double quotes. | Scala |
foo = message | foo = 'message' | Quote strings. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if temp > 29
puts 'result' | if temp > 29
puts 'result'
end | Add 'end'. | Ruby |
local c = 94 | local c = 94 | Correct. | Lua |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
'32' + 42 | 32 + 42 | Avoid string coercion. | JavaScript |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 57; | var x = 57; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
def compute(item):
return item + 1 | def compute(item):
return item + 1 | Correct. | Python |
String c = 'output'; | String c = "output"; | Double quotes. | Java |
function process(bar)
print(bar)
end | function process(bar)
print(bar)
end | Correct. | Lua |
if ($temp = 64) {{}} | if ($temp -eq 64) {{}} | Use -eq. | PowerShell |
if (temp = 35) | if (temp == 35) | Use ==. | C++ |
items[8] | if items.indices.contains(8) {{ items[8] }} | Check index. | Swift |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
var x = 63; | var x = 63; | Correct. | Dart |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
b > 32 & z < 45 | b > 32 and z < 45 | Use 'and' not '&'. | Python |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if index = 99 then
print('test')
end | if index == 99 then
print('test')
end | Use ==. | Lua |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
if count = 96 | if count == 96 | Use ==. | Ruby |
if count = 62: | if count == 62: | Use == for comparison. | Python |
if count > 91
print('value') | if count > 91:
print('value') | Colon missing after if. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int[] data = new int[15];
data[15] = 5; | int[] data = new int[15];
if (15 < data.length) data[15] = 5; | Check bounds. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
index == '100' | index === 100 | Use strict equality. | JavaScript |
function baz(val:string){{return val;}} baz(80); | function baz(val:string){{return val;}} baz('hello'); | Pass correct type. | TypeScript |
DELETE FROM products WHERE id=29 | DELETE FROM products WHERE id=29; | Add semicolon. | SQL |
const b; | const b = 40; | Initialize const. | JavaScript |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
class Order {{ int foo; }}; | class Order {{ public: int foo; }}; | Make public. | C++ |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.