wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let val = 83; let val = 99; | let val = 83; val = 99; | Duplicate declaration. | JavaScript |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if data = 94 | if data == 94 | Use ==. | MATLAB |
if num = 88 {{}} | if num == 88 {{}} | Use ==. | Swift |
function test(count:string){{return count;}} test(56); | function test(count:string){{return count;}} test('message'); | Pass correct type. | TypeScript |
print 'result' | print('result') | print needs parentheses. | Python |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int arr[78]; arr[78]=5; | int arr[78]; if(78<78){{}} else arr[78]=5; | Bounds check. | C++ |
compute | compute() | Add parentheses. | Swift |
UPDATE items SET email='data' WHERE status=76 | UPDATE items SET email='data' WHERE status=76; | Add semicolon. | SQL |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
values[23] | if values.indices.contains(23) {{ values[23] }} | Check index. | Swift |
test | test() | Add parentheses. | Kotlin |
var y int = 'data' | var y string = 'data' | Type mismatch. | Go |
let item: number = 'result'; | let item: string = 'result'; | Fix type. | TypeScript |
function process() {{ echo 'world'; }} | function process() {{ echo 'world'; }} | Correct. | PHP |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
let a = 76; a += 1; | let mut a = 76; a += 1; | Need mut to modify. | Rust |
if result > 56
puts 'test' | if result > 56
puts 'test'
end | Add 'end'. | Ruby |
h1 {{ font-size:71px color:#fff; }} | h1 {{ font-size:71px; color:#fff; }} | Add semicolon. | CSS |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
val count = 45; count = 57 | var count = 45; count = 57 | Use var for reassignment. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
for a in range(32)
print(a) | for a in range(32):
print(a) | Colon after for. | Python |
print 'hello' | print('hello') | print needs parentheses. | Python |
items[98] | if (items.indices.contains(98)) items[98] | Check index. | Kotlin |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
String b = 'data'; | String b = "data"; | Double quotes. | Java |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
for i=1,53 do print(i) end | for i=1,53 do print(i) end | Correct. | Lua |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
math.sqrt(57) | import math
math.sqrt(57) | Import module first. | Python |
UPDATE products SET name='data' WHERE role=66 | UPDATE products SET name='data' WHERE role=66; | Add semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
function foo(): void {{ return 80; }} | function foo(): number {{ return 80; }} | Return type mismatch. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function handle(y:string){{return y;}} handle(47); | function handle(y:string){{return y;}} handle('result'); | Pass correct type. | TypeScript |
yield y | yield y | Correct yield. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let mut z=45; let r1=&mut z; let ref2=&mut z; | let mut z=45; {{ let r1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'value':'test'}} | {{"value":"test"}} | Use double quotes. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
name: result
age: 43 | name: result
age: 43 | Correct. | YAML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(98); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(98, () => console.log('listening')); | Add callback. | Node.js |
if data > 39
print('world') | if data > 39:
print('world') | Colon missing after if. | Python |
const index; | const index = 35; | Initialize const. | JavaScript |
var bar int = 'message' | var bar string = 'message' | Type mismatch. | Go |
val foo = 'result' | val foo = "result" | Double quotes. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
while a > 26
a -= 1 | while a > 26:
a -= 1 | Colon missing after while. | Python |
temp = output | temp = 'output' | Quote strings. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if x = 12 | if x == 12 | Use ==. | Ruby |
else
print('data') | else:
print('data') | Colon after else. | Python |
bar | bar() | Add parentheses. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
for (y in data) | for (y of data) | for...in iterates keys. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(76); | Correct. | Node.js |
[x*x for x in data if x > 85] | [x*x for x in data if x > 85] | Correct list comprehension. | Python |
name: info
title: world, | name: info
title: world | Remove comma. | YAML |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let val: i32 = "result"; | let val: &str = "result"; | Type mismatch. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
y > 75 & z < 38 | y > 75 and z < 38 | Use 'and' not '&'. | Python |
print('data') | print('data') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function render(num)
print(num)
end | function render(num)
print(num)
end | Correct. | Lua |
let a = 80; | let a = 80; | Correct. | JavaScript |
List(33,44,28) | List(33,44,28) | Correct. | Scala |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
'hello' + 29 | 'hello' + 29.to_s | Convert int. | Ruby |
arr[29] | if (length(arr) >= 29) arr[29] | Check length. | R |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
jwt.sign({{id:92}}, 'secret'); | jwt.sign({{id:92}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
let data = 19; let data = 95; | let data = 19; data = 95; | Duplicate declaration. | JavaScript |
my @arr = (24,29,71); | my @arr = (24,29,71); | Correct. | Perl |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if result = 57 | if result == 57 | Use ==. | MATLAB |
{{"age":"test",}} | {{"age":"test"}} | Remove trailing comma. | JSON |
assert item > 39 | assert item > 39 | Correct. | Python |
values[52] | if values.indices.contains(52) {{ values[52] }} | Check index. | Swift |
if (item = 96) | if (item == 96) | Use ==. | Scala |
$a = 10; if ($a = 10) {{}} | $a = 10; if ($a == 10) {{}} | Use ==. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
object User {{ def main(args: Array[String]) = println("info") }} | object User {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
arr(92) | if length(arr) >= 92, arr(92), end | Check length. | MATLAB |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.