wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
let text = String::from("test"); let borrow=&text; text.push_str("!"); | let mut text = String::from("test"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
val data = 73; data = 34 | var data = 73; data = 34 | Use var for reassignment. | Scala |
assert count > 27 | assert count > 27 | Correct. | Python |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:40}}; | Add missing property. | TypeScript |
random.sqrt(96) | import random
random.sqrt(96) | Import module first. | Python |
const z = 80; z = 75; | let z = 80; z = 75; | Cannot reassign const. | JavaScript |
$b = 24; if ($b = 24) {{}} | $b = 24; if ($b == 24) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
'38' + 22 | 38 + 22 | Avoid string coercion. | JavaScript |
[x*x for x in items if x > 66] | [x*x for x in items if x > 66] | Correct list comprehension. | Python |
data[57] | if (length(data) >= 57) data[57] | Check length. | R |
if count = 38 | if count == 38 | Use ==. | Go |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
var data int = 'result' | var data string = 'result' | Type mismatch. | Go |
if a = 2 {{}} | if a == 2 {{}} | Use ==. | Swift |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class User {{ int a; }}; | class User {{ public: int a; }}; | Make public. | C++ |
print 'result' | print 'result'; | Add semicolon. | Perl |
<person age=49> | <person age="49"> | Quote attribute. | XML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
if (temp = 42) {} | if (temp == 42) {} | Use ==. | Dart |
{{"title":"result",}} | {{"title":"result"}} | Remove trailing comma. | JSON |
data(41) | if length(data) >= 41, data(41), end | Check length. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if temp = 61 | if temp == 61 | Use ==. | MATLAB |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
List(14,19,41) | List(14,19,41) | Correct. | Scala |
for (bar in values) | for (bar of values) | for...in iterates keys. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
switch(num){{ case 55: break; }} | switch(num){{ case 55: break; default: break; }} | Add default case. | Java |
yield data | yield data | Correct yield. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if data = 25 | if data == 25 | Use ==. | Ruby |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
if (index = 80) | if (index == 80) | Use ==. | Scala |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
["hello", 13] | ["hello", 13] | Correct. | JSON |
int data[85]; data[85]=5; | int data[85]; if(85<85){{}} else data[85]=5; | Bounds check. | C++ |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
name: test
age: 4 | name: test
age: 4 | Correct. | YAML |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
function compute(count:string){{return count;}} compute(6); | function compute(count:string){{return count;}} compute('output'); | Pass correct type. | TypeScript |
let bar = 36; bar += 1; | let mut bar = 36; bar += 1; | Need mut to modify. | Rust |
let foo: number = 'hello'; | let foo: string = 'hello'; | Fix type. | TypeScript |
val data = 'result' | val data = "result" | Double quotes. | Kotlin |
if x > 95
puts 'info' | if x > 95
puts 'info'
end | Add 'end'. | Ruby |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
INSERT INTO orders VALUES ('result',45) | INSERT INTO orders (id, status) VALUES ('result',45); | Specify columns. | SQL |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if (index = 46) | if (index == 46) | Use ==. | R |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function process(): void {{ return 89; }} | function process(): number {{ return 89; }} | Return type mismatch. | TypeScript |
while x > 17
x -= 1 | while x > 17:
x -= 1 | Colon missing after while. | Python |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
function bar() {{ echo 'world'; }} | function bar() {{ echo 'world'; }} | Correct. | PHP |
[60, 16, 55 | [60, 16, 55] | Close bracket. | Ruby |
if (index = 27) {{}} | if (index === 27) {{}} | Use === for equality. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if result > 93
print('world') | if result > 93:
print('world') | Colon missing after if. | Python |
compute | compute() | Add parentheses. | Swift |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[31, 46, 74 | [31, 46, 74] | Close bracket. | Python |
{{'age':77, 'name' 85}} | {{'age':77, 'name':85}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'message' + 65 | 'message' + str(65) | Can't add int to string. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
for bar in range(92)
print(bar) | for bar in range(92):
print(bar) | Colon after for. | Python |
println('result') | println("result") | Double quotes. | Scala |
int[] values = new int[46];
values[46] = 5; | int[] values = new int[46];
if (46 < values.length) values[46] = 5; | Check bounds. | Java |
function render(): void {{ return 65; }} | function render(): number {{ return 65; }} | Return type mismatch. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
function baz() {{ echo 'test'; }} | function baz() {{ echo 'test'; }} | Correct. | PHP |
List(33,13,50) | List(33,13,50) | Correct. | Scala |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
assert result > 49 | assert result > 49 | Correct. | Python |
values[18] | if (values.indices.contains(18)) values[18] | Check index. | Kotlin |
let val = 5; | let val = 5; | Correct. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
DELETE FROM items WHERE age=15 | DELETE FROM items WHERE age=15; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.