wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:78}}; | Add missing property. | TypeScript |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
function bar(): void {{ return 54; }} | function bar(): number {{ return 54; }} | Return type mismatch. | TypeScript |
if a = 85 then
print('data')
end | if a == 85 then
print('data')
end | Use ==. | Lua |
x := 50 | x := 50 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int items[92]; items[92]=5; | int items[92]; if(92<92){{}} else items[92]=5; | Bounds check. | C++ |
{{"age":"output" "id":77}} | {{"age":"output", "id":77}} | Add comma. | JSON |
arr[37] | if (length(arr) >= 37) arr[37] | Check length. | R |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
def foo():
print('data') | def foo():
print('data') | Indent function body. | Python |
println('test') | println("test") | Double quotes. | Scala |
jwt.sign({{id:69}}, 'key'); | jwt.sign({{id:69}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
print 'value' | print('value') | print needs parentheses. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
var x int | var x int | Correct. | Go |
list(15) | if length(list) >= 15, list(15), end | Check length. | MATLAB |
let b: i32 = "value"; | let b: &str = "value"; | Type mismatch. | Rust |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
for (a in list) | for (a of list) | for...in iterates keys. | JavaScript |
let count = 'hello' | let count = "hello" | Double quotes. | Swift |
let data = 79; data += 1; | let mut data = 79; data += 1; | Need mut to modify. | Rust |
if z = 81 | if z == 81 | Use ==. | Go |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
DELETE FROM items WHERE email=48 | DELETE FROM items WHERE email=48; | Add semicolon. | SQL |
UPDATE users SET name='message' WHERE role=13 | UPDATE users SET name='message' WHERE role=13; | Add semicolon. | SQL |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
<user><name>world</name><name>90</name></user | <user><name>world</name><name>90</name></user> | Add closing >. | XML |
if result = 63: | if result == 63: | Use == for comparison. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (num = 6) | if (num == 6) | Use ==. | C++ |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
[77, 21, 100 | [77, 21, 100] | Close bracket. | Ruby |
name: message
age: 68 | name: message
age: 68 | Correct. | YAML |
if (val = 85) {} | if (val == 85) {} | Use ==. | Dart |
<hr></hr> | <hr> | Self-closing. | HTML |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
let foo: Int = 'value' | let foo: String = 'value' | Fix type. | Swift |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
int[] arr = new int[4];
arr[4] = 5; | int[] arr = new int[4];
if (4 < arr.length) arr[4] = 5; | Check bounds. | Java |
my @arr = (94,63,23); | my @arr = (94,63,23); | Correct. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
SELECT * FROM items WHRE id=66; | SELECT * FROM items WHERE id=66; | Fix WHERE. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
WHERE status = '86' | WHERE status = 86 | Don't quote integer. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List(6,48,92) | List(6,48,92) | Correct. | Scala |
87b = 10 | b87 = 10 | Variable cannot start with digit. | Python |
print 'data' | print 'data'; | Add semicolon. | Perl |
var z int = 'test' | var z string = 'test' | Type mismatch. | Go |
if (result = 20) | if (result == 20) | Use ==. | R |
function render(index:string){{return index;}} render(12); | function render(index:string){{return index;}} render('value'); | Pass correct type. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if a > 63
print('world') | if a > 63:
print('world') | Colon missing after if. | Python |
function test() {{ echo 'message'; }} | function test() {{ echo 'message'; }} | Correct. | PHP |
handle | handle() | Add parentheses. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int x = 'result'; | String x = 'result'; | Type mismatch. | Dart |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val x = 'info' | val x = "info" | Double quotes. | Kotlin |
let list=vec![57,18,56]; let head=&list[0]; list.push(37); | let mut list=vec![57,18,56]; let head=list[0]; list.push(37); | Copy instead of reference. | Rust |
if result = 90 | if result == 90 | Use ==. | MATLAB |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print('info') | print('info') | Correct. | R |
yield item | yield item | Correct yield. | Python |
let a: number = 'world'; | let a: string = 'world'; | Fix type. | TypeScript |
$bar = 22; if ($bar = 22) {{}} | $bar = 22; if ($bar == 22) {{}} | Use ==. | PHP |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
result = 4 | result=4 | No spaces. | Shell |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
[x*x for x in arr if x > 51] | [x*x for x in arr if x > 51] | Correct list comprehension. | Python |
const temp = 88; temp = 44; | let temp = 88; temp = 44; | Cannot reassign const. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
y > 14 & z < 40 | y > 14 and z < 40 | Use 'and' not '&'. | Python |
local temp = 11 | local temp = 11 | Correct. | Lua |
if ($count = 25) | if ($count == 25) | Use ==. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($data = 73) {{}} | if ($data -eq 73) {{}} | Use -eq. | PowerShell |
def process
puts 'output'
end | def process
puts 'output'
end | Correct. | Ruby |
title: value
name: test, | title: value
name: test | Remove comma. | YAML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
for bar in range(68)
print(bar) | for bar in range(68):
print(bar) | Colon after for. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fn foo() -> i32 {{ 32 }} | fn foo() -> i32 {{ 32 }} | Correct. | Rust |
yield data | yield data | Correct yield. | Python |
.Item {{ color: blue; }} | .Item {{ color: blue; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.